You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fa44e7e
Browse filesBrowse the repository at this point in the historyBrowse files
fix(sw): hold cache writes open past the response they came from
CI caught what local runs cannot: E2E shard 2 failed with /sdkjs/slide/sdk-all.js
missing from the cache -- the last file of the warm-up queue.
The cause is not the test. `respondWith` settles the moment the response is
handed to the page, and a worker with nothing else outstanding may be terminated
right there, taking a half-finished `cache.put` with it. The larger the file the
wider that window, which is backwards: the 13.7 MB SDK is the entry most worth
keeping. Nothing pressures the worker to shut down locally, so it never showed.
Every cache write in the fetch handler is now inside event.waitUntil: the vendor
cache-first branch, the stale-while-revalidate branch, and both CORE_CACHE
writes on the network-first path (smaller files, identical failure mode). This
is a correctness fix for production, not a way to make a test pass.
The test was also asserting too much: the page's promise settles when the last
response has been read, while the worker's put completes on its own side a
moment later. Demanding both at the same instant is the assertion's error, so it
polls for eventual consistency instead.
waitUntil itself resists a runtime test -- reliably provoking "the worker is
terminated now" is not something a spec can do -- so it is pinned as a source
contract, the way landing-pages and workflow-contract already pin theirs: every
putInRuntimeCache call site must sit inside event.waitUntil, and every
caches.open(CORE_CACHE) in the fetch handler must be immediately preceded by it.
Reverse-verified: reverting either to a bare call turns the contract red.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
0 commit comments