[Website] Handle failed background CacheStorage writes - #4202
Open
adamziel wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Prevents unhandled promise rejections when Cache.put() fails in background cache writes by explicitly settling (catching) the non-awaited cache-write promises.
Changes:
- Wrap background
offlineModeCache.put(...)calls invoid ... .catch(...)in both cache-first and network-first paths. - Add Vitest coverage to ensure failed background writes are settled without blocking the response.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/playground/remote/src/lib/offline-mode-cache.ts | Adds explicit .catch() handling for non-awaited Cache.put() promises to avoid unhandled rejections. |
| packages/playground/remote/src/lib/offline-mode-cache.spec.ts | Adds tests verifying the background cache-write rejection is observed/handled for both strategies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
The cache-first and network-first paths intentionally return the network response without waiting for
Cache.put(). A failed background write therefore rejected an unobserved promise, which Chrome reported as an uncaughtNetworkErrorduring boot.Settle both background cache-write promises while keeping response delivery non-blocking. A failed write still means that asset will not be available offline, but it no longer leaks an unhandled rejection into the page.
This addresses the
Cache.put()half of #1943.Testing
Force
Cache.put()to reject in both caching strategies and confirm the network response still resolves without an unhandled rejection.