From f67abc05d76d4e0025b2898edcc678dea121a1dc Mon Sep 17 00:00:00 2001 From: Evie Gauthier Date: Fri, 13 Mar 2026 22:25:30 -0400 Subject: [PATCH] fix: format src/index.tsx and add changeset --- .changeset/fix-media-chunk-errors.md | 5 +++++ src/index.tsx | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/fix-media-chunk-errors.md diff --git a/.changeset/fix-media-chunk-errors.md b/.changeset/fix-media-chunk-errors.md new file mode 100644 index 00000000..d6c55186 --- /dev/null +++ b/.changeset/fix-media-chunk-errors.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fixed unhandled promise rejections in media blob cache and added automatic retry for chunk loading failures after deployments. diff --git a/src/index.tsx b/src/index.tsx index 53944ef3..3248458b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -148,17 +148,17 @@ window.addEventListener('error', (event) => { const isChunkLoadError = event.message?.includes('dynamically imported module') || event.message?.includes('Failed to fetch') || - (event.error?.name === 'ChunkLoadError'); + event.error?.name === 'ChunkLoadError'; if (isChunkLoadError) { const retryCount = parseInt(sessionStorage.getItem(CHUNK_RETRY_KEY) ?? '0', 10); - + if (retryCount < MAX_CHUNK_RETRIES) { // Increment retry count and reload sessionStorage.setItem(CHUNK_RETRY_KEY, String(retryCount + 1)); log.warn(`Chunk load failed, reloading (attempt ${retryCount + 1}/${MAX_CHUNK_RETRIES})`); window.location.reload(); - + // Prevent default error handling since we're reloading event.preventDefault(); } else {