Skip to content

should FetchEvent.request.signal reflect abort status of outer request? #1544

Open
@wanderview

Description

@wanderview

Consider a service worker script that looks like:

  self.addEventListener('fetch', evt => {
    evt.respondWith(fetch(evt.request));
  });

And that the controlled page does the following:

  const controller = new AbortController();
  fetch(url, { signal: controller.signal });
  if (some_condition) {
    controller.abort();
  }

Should the fetch() initiated by the service worker script be aborted in this case? I think it would be good to do so.

I'm unsure this is what the spec says, though. It seems that in Handle Fetch we create a Request from an inner request in step 21.3.2:

https://w3c.github.io/ServiceWorker/#on-fetch-request-algorithm

The fetch spec, however, does not have an abort signal on the inner request:

https://fetch.spec.whatwg.org/#concept-request

Its only present on the exposed Request object:

https://fetch.spec.whatwg.org/#request-signal

This implies that Handle Fetch effectively strips the AbortSignal from the request when generating FetchEvent.request. Is that intentional?

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