v159 · service worker · advanced composition
App-shell revalidation
A common composition: answer instantly from a cached shell, then refresh that cache in the background (stale-while-revalidate). Put the URL behind a "race-network-and-fetch-handler" route and the obvious refresh, fetch(event.request), rides on the raced request — which the browser cancels the moment your cached response wins. The refresh dies, the cache never updates, and until Chrome 159 the only trace was a Failed to fetch
that looked like an outage. Try both refresh strategies against a live Cache Storage entry.
Load through the shell
Cached shell entry
Last background refresh
the two refresh strategies
// A: rides the race — cancelled as soon as the shell answers
const refresh = fetch(event.request);
// Chrome 159+: TypeError "The service worker race-network-and-fetch-handler
// request was cancelled before 'fetch()' settled."
// earlier: TypeError "Failed to fetch"
// B: an independent request — not deduplicated, not cancelled
const refresh = fetch(event.request.url, { cache: "no-store" });
event.waitUntil(refresh.then((r) => cache.put(SHELL_KEY, r.clone())));
event.respondWith(caches.match(SHELL_KEY));
Strategy B costs a second network request (the browser’s own raced request is still made and then dropped). The cleaner fix is often to not race at all for cache-first URLs — route them with source: "cache" or plain "fetch-event" — and keep "race-network-and-fetch-handler" for URLs where you actually want the network response. The new message is what lets you notice you have this bug: a stream of “cancelled before ‘fetch()’ settled” in your refresh path is a design smell, not an outage.