fix: Media blob cache and chunk loading error handling#255
Merged
Just-Insane merged 3 commits intoSableClient:devfrom Mar 14, 2026
Merged
fix: Media blob cache and chunk loading error handling#255Just-Insane merged 3 commits intoSableClient:devfrom
Just-Insane merged 3 commits intoSableClient:devfrom
Conversation
added 2 commits
March 13, 2026 21:20
Fixes unhandled promise rejection when multiple components fetch the same media URL and the initial request fails with 401. ### Root Cause When a blob fetch request was in-flight and failed, subsequent callers awaiting the same promise would receive an unhandled rejection because the await was outside the try-catch block. ### Changes 1. useBlobCache: Wrap inflightRequests.get() await in try-catch 2. useBlobCache: Improve error message to include HTTP status 3. Service Worker: Add logging for session retrieval failures to diagnose authentication issues with media requests Addresses Sentry issue with 401 errors on authenticated media endpoints.
- Global error handler catches chunk load errors - Auto-reload on first 2 failures without user intervention - On 3rd failure, let error bubble to Sentry error boundary - Uses sessionStorage to track retry count across reloads - Clears counter on successful page load - Prevents stale HTML from breaking app after deployments
bff8c3d to
24fbbc0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds robust error handling for two types of client errors:
1. Unhandled Promise Rejection in Media Blob Cache (Commit 77046ab)
Fixes unhandled promise rejections when multiple components fetch the same media URL that fails with 401 errors.
Root Cause: When a blob fetch request was in-flight and failed, subsequent callers awaiting the same promise would receive an unhandled rejection because the await was outside the try-catch block.
Changes:
inflightRequests.get()await in try-catch blockAddresses: Sentry Issue #1 (401 errors on authenticated media endpoints)
2. Automatic Retry for Chunk Loading Failures (Commit bff8c3d)
Adds automatic page reload when dynamic import failures occur due to stale HTML after deployments.
Root Cause: After deployments, users with cached HTML try to load JS chunks that no longer exist, causing "Failed to fetch dynamically imported module" errors.
Changes:
Addresses: Sentry Issue #2 (stale HTML breaking app after deployments)
Testing