4

I want to completely remove a service worker from my website that I initially put there without really thinking about it. I tried the unregister method from react-scripts v1.0.17 default registerServerWorker.js implementation:

export function unregister() {
  if ('serviceWorker' in navigator) {
    navigator.serviceWorker.ready.then(registration => {
      registration.unregister();
    });
  }
}

In the Chrome dev tools, I see that the service worker is affected by the call to unregister: a '- deleted' appears next to the hostname and the "update" and "unregister" links are greyed out. But the state is still "activated and is running". If I unregister it manually with the dev tools it disappears completely, like I would expect. This makes me think that the programmtic unregister command is failing or maybe not enough.

I tried looking up how to stop an SW programmatically but the examples only talk about unregistration. Can somebody shed some light on this?

Cpt. Senkfuss
  • 1,347
  • 3
  • 12
  • 20
  • 1
    You may consider providing the exact code you're using to unregister. – anthumchris Mar 13 '18 at 22:19
  • Possible duplicate of [How do I uninstall a Service Worker?](https://stackoverflow.com/questions/33704791/how-do-i-uninstall-a-service-worker) – anthumchris Mar 13 '18 at 22:20
  • @cøder Your link is about how to unregister the SW. My question is about what happens in Chrome when I unregister the SW and how it differs from the results I get from the dev tools. So no, no duplicate. – Cpt. Senkfuss Mar 15 '18 at 09:23
  • 1
    Have you had any luck with this? I have the same issue – anonymouse Aug 13 '19 at 18:47
  • 1
    I've the same issue too. Worker is stil activated and running even if I unregistered it – Pierre-Luc Oct 28 '21 at 09:24

0 Answers0