Skip to content

Should active service worker for service worker be itself? #1850

Open

Description

@ltenmoz

The active service worker is specified for windows, dedicated worker, and shared worker clients here: https://w3c.github.io/ServiceWorker/#control-and-use, but not for service workers.

This means that fetches originating from service workers cannot be intercepted, due to step 10 of handle fetch:

  1. Else if request is a subresource request, then:
    1 If client’s active service worker is non-null, set registration to client’s active service worker’s containing service worker registration.
    2 Else, return null.

However, in whatwg/fetch#303, it was decided that for showNotification(), the image requests should always be intercepted, even if the notification is created from a service worker. So perhaps we need to specify that for a service worker, the active service worker is itself (well, it's a bit awkward because "service worker client" already has a different definition from "a client that is a service worker").

Activity

  1. yoshisatoyanagisawa commented on Sep 28, 2026

    @yoshisatoyanagisawa
    Collaborator

    Unfortunately, I do not have a clear answer for this. As you know, simply allowing the fetch handler to intercept fetches from Service Workers can easily cause an infinite fetch loop. Therefore, I feel it is difficult to settle the service worker intercept requested from showNotification() while avoiding this infinite loop.
    Maybe we should bypass the fetch handler/interception if the service worker itself is the initiator?
    Let me leave this open and revisit this later.

  2. ltenmoz commented on Sep 28, 2026

    @ltenmoz
    Author

    There was some discussion about how to avoid infinite loops in the original issue: whatwg/fetch#303 (comment).

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