If an expection is thrown in the activate phase, the service worker should be terminated
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 3.6k
- Forks
- 324
- Avg merge
- 14d 22h
- Merged PRs (30d)
- 1
Description
Right now, nothing happens, but since on activate u can do stuff like move from a temp cache to a proper one and then delete the temp cache, if an exception is thrown the service worker will be in a "not completed" state, but will control the page anyway, which could lead to unexpected bugs
My solution right is to try catch the activate and do:
let clients = await self.clients.matchAll();
await self.registration.unregister();
clients.forEach(client => client.navigate(client.url));
which seems to work, but there is another bug I added which might make it fail: https://github.com/w3c/ServiceWorker/issues/1687
To me, it seems like an expectation should abort the service worker, and if u don't want that, u can always try catch it and do nothing to prevent the "abort".
Or an option to abort the service worker should be added so we can call it on activate.
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 by reviewing the service worker activate phase and the lifecycle behavior described in the issue. Compare the proposed clients.matchAll(), unregister(), and client navigation sequence with the related issue 1687. Done means the desired behavior for exceptions during activation is specified and supported without leaving a worker controlling pages in an incomplete state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100