Skip to content

Add Unregister Service Workers algorithm for use by other specifications - #1849

Open
monica-ch wants to merge 2 commits into
w3c:mainfrom
monica-ch:add-unregister-service-workers
Open

monica-ch wants to merge 2 commits into
w3c:mainfrom
monica-ch:add-unregister-service-workers

Conversation

@monica-ch

@monica-ch monica-ch commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #1846.

This introduces a new exported algorithm — a stable public surface that external specifications can bind to.

Change

Adds an exported Unregister Service Workers algorithm so other specifications such as FedCM and Payment Handler can schedule unregistration of all service worker registrations for a storage key.

Algorithm

Input: storage key
Output: none

The algorithm:

  1. collects the serialized scopes whose storage keys compare equal to the input;
  2. parses each scope URL; and
  3. creates and schedules an unregister job for each valid scope.

Collecting the scopes before scheduling avoids iterating the registration map while unregister jobs can modify it.

Completion contract

The algorithm is intentionally fire-and-forget. It does not wait for the unregister jobs to finish, so matching registration-map entries might still exist when it returns.

Waiting for the jobs would only guarantee removal from the registration map. It would not guarantee physical destruction: Clear Registration can remain delayed while a client uses the registration or the registration's workers have pending lifetime work.

This matches the current FedCM teardown model, which stops dispatching to the identity handler when its declaration is removed and allows the registration itself to be removed asynchronously. Clear-Site-Data similarly invokes service worker unregistration without waiting for its promise.

Adoption implications

Related


Preview | Diff

Add a new exported algorithm that other specifications (FedCM, Payment Handler) can call to unregister all service worker registrations for a given storage key (for example, when an identity handler or payment app declaration has been removed).

The algorithm iterates the registration map for entries matching the given storage key, parses each serialized scope URL, and schedules an unregister job per scope. Fire-and-forget: no completion or failure signal is delivered to the caller.

Part of w3c#1846.
@monica-ch
monica-ch force-pushed the add-unregister-service-workers branch from 8cc9612 to 5aef2ee Compare September 2, 2026 19:33
@monica-ch monica-ch changed the title Editorial: add exported Unregister Service Workers algorithm Add Unregister Service Workers algorithm for use by other specifications Sep 4, 2026
@monica-ch
monica-ch marked this pull request as ready for review September 4, 2026 22:03
@monica-ch

Copy link
Copy Markdown
Collaborator Author

@yoshisatoyanagisawa CYTAL, thanks!

Comment thread index.bs Outdated
@yoshisatoyanagisawa

Copy link
Copy Markdown
Collaborator

The algorithm reminds me Clear-Site-Data: "storage" (https://w3c.github.io/webappsec-clear-site-data/#clear-dom). Overall looks good to me, but let me ask if we need to allow callers to ensure the removal or not.

Use structural storage-key equality and document that the exported bulk
unregister algorithm schedules jobs without waiting for registration-map
removal or eventual registration clearing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e60256f0-04fc-4a2f-b93c-ca14f2fea252
@monica-ch

monica-ch commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

Thanks @yoshisatoyanagisawa. I investigated the completion question and kept this fire-and-forget.
Ordinary unregistration completion only confirms that the registration is no longer available for matching; full clearing can remain delayed while clients or lifetime work still use it. Chromium similarly has a separate  DeleteForStorageKey  operation for callers such as storage clearing that require stronger deletion guarantees.

FedCM only needs to stop dispatching when the declaration disappears and permits cleanup to happen asynchronously, so ordinary bulk unregistration appears sufficient here.

@Brandr0id, could you confirm that this asynchronous contract works for the FedCM identity-handler teardown path?
If another caller needs durable storage-deletion semantics, I think that should be a separate exported algorithm rather than changing this ordinary unregister wrapper.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants