[w3c/ServiceWorker] If an expection is thrown in the activate phase, the service worker should be terminated (Issue #1688)

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:

  ``` js
      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.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1688
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/ServiceWorker/issues/1688@github.com>

Received on Wednesday, 19 July 2023 15:36:04 UTC