Re: [w3c/ServiceWorker] cache.addAll() is not consistent in aborting outstanding requests on error (#1543)

mcollina left a comment (w3c/ServiceWorker#1543)

Another inconsistency in the same loop: in step 5 of `addAll`, each request is constructed and its fetch is started before the next one is processed. If a later entry fails at step 5.2 (non-HTTP(S) scheme), earlier fetches are aborted, but if it fails at step 5.1 (the `Request` constructor throws, e.g. `cache.addAll(['/valid', 'http://[invalid'])`), the promise is rejected and the fetches already started are neither aborted nor awaited. Read literally, the earlier requests still go out on the wire.

Browsers don't do this: they construct and validate the whole list before starting any fetch ([Chromium](https://github.com/chromium/chromium/blob/661e96150d2113b01061de3521dce53bf149c499/third_party/blink/renderer/modules/cache_storage/cache.cc#L1128-L1170), [Firefox](https://github.com/mozilla-firefox/firefox/blob/2edaa9b6633031ade3ee4bed787affa82c93424b/dom/cache/Cache.cpp#L314-L358)). So in both, `addAll([valid, invalid])` rejects without sending any request.

Would it make sense to split step 5 into two loops, one that constructs and validates every request (steps 5.1–5.4) and one that starts the fetches, to match implementations? That would also make the "abort fetchControllers" substep in 5.2 unnecessary.

For context, undici (Node.js's fetch and Cache implementation) is adopting the browser behavior in nodejs/undici#6254, after we found that the current interleaving can leave the early fetch's promise rejected with nothing handling it.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1543#issuecomment-7129165217
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/ServiceWorker/issues/1543/7129165217@github.com>

Received on Tuesday, 24 November 2026 10:44:46 UTC