Support `close()` method in ServiceWorkerGlobalScope
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 3.6k
- Forks
- 324
- Avg merge
- 14d 22h
- Merged PRs (30d)
- 1
Description
close() is supported in the DedicatedWorkerGlobalScope (source), but not the ServiceWorkerGlobalScope.
In Manifest V3, the latest version of the Web Extensions platform, extensions can use service workers as a background context. In the Web Extensions Community Group, we have been discussing a feature request to support the immediate termination of a service worker.
We would prefer a spec level solution over an extension specific API so filing this issue.
There are a few key use cases we have identified:
- A developer is handling sensitive data in the service worker (e.g a password manager). When the user asks the password manager to lock, immediately terminating the service worker would provide some additional certainty that any data in memory can be freed (source).
- A developer is writing tests and wants to immediately terminate the service worker (source).
- In general, a service worker no longer has any work to perform and wishes to free up resources.
I found https://github.com/w3c/ServiceWorker/issues/865 which has some of the history: it appears this initially threw an error, and was then moved to avoid exposing it entirely. But I couldn't find any specific motivations for not supporting it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ServiceWorkerGlobalScope specification and review the linked history in w3c/ServiceWorker#865 and Web Extensions #311. The issue requires deciding whether and how close() should be specified; done would require a resolved spec change and agreement on its termination semantics.
Written by the indexing model from the issue text.
Assessment
- Domain
- api, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100