Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If an expection is thrown in the activate phase, the service worker should be terminated #1688

Open
signorpipo opened this issue Jul 19, 2023 · 0 comments

Comments

@signorpipo
Copy link

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: #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.

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

No branches or pull requests

1 participant