Skip to content

[Website] Handle failed background CacheStorage writes - #4202

Open
adamziel wants to merge 2 commits into
trunkfrom
adamziel/settle-offline-cache-write-failures
Open

[Website] Handle failed background CacheStorage writes#4202
adamziel wants to merge 2 commits into
trunkfrom
adamziel/settle-offline-cache-write-failures

Conversation

@adamziel

Copy link
Copy Markdown
Collaborator

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 uncaught NetworkError during 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.

Copilot AI review requested due to automatic review settings July 29, 2026 13:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in void ... .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.

Comment thread packages/playground/remote/src/lib/offline-mode-cache.ts
Comment thread packages/playground/remote/src/lib/offline-mode-cache.ts
Comment thread packages/playground/remote/src/lib/offline-mode-cache.spec.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants