Skip to content

cache.addAll() is not consistent in aborting outstanding requests on error #1543

Open

Description

@wanderview

In the cache.addAll() algorithm:

https://w3c.github.io/ServiceWorker/#cache-addAll

The spec periodically cancels outstanding requests with text like:

Terminate all the ongoing fetches initiated by requests with the aborted flag set.

However, it does not appear to do this if the fetch() rejects instead of resolving a promise. It also does not do this if a resolved Response has ok() return false, status code is 206, etc.

Also, does this kind of termination cause the associated Request.signal to expose the abort status? I'm having a hard time understanding that from the spec. @jakearchibald do you know?

Activity

  1. wanderview commented on Sep 28, 2020

    @wanderview
    MemberAuthor

    I'd like to write some cache.addAll() abort WPT tests and being able to test abort status on the signal would make things a lot easier.

  2. wanderview commented on Sep 29, 2020

    @wanderview
    MemberAuthor

    I guess if cache.addAll() aborts internally it is not exposed to the script's AbortSignal. It seems the Request constructor always creates a new AbortSignal which then follows the original signal. This means the signal flows into the new Request, but if we abort the new Request signal internally the info does not flow back out to the script.

    So I'm not sure if its really possible to test if outstanding requests are cancelled when one request in addAll() fails.

  3. monica-ch commented on Oct 23, 2026

    @monica-ch
    Collaborator

    [Bug triage] Issue still exists, needs editorial fixes. Understand what browsers are doing from the test https://github.com/web-platform-tests/wpt/blob/master/service-workers/cache-storage/cache-add.https.any.js and update spec accordingly

  4. mcollina commented on Nov 24, 2026

    @mcollina

    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, Firefox). 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions