I have a bad service worker that is no longer updating. I noticed the issue in Chrome first. I then put the following code in the index.html file and in the sw.js (service worker) file. For the most part it seems to be working fine. Firefox seems to be the only browser that is not removing the service worker. I used the article below to create the unregister script.
How do I uninstall a Service Worker?
I have also used this article and code and got the same results.
How can I remove a buggy service worker, or implement a "kill switch"?
I am also receiving an error message for getRegistrations()
saying it is undefined. Not sure how to fix that either.
Help with both of these issues would be greatly appreciated.
<script>
navigator.serviceWorker.getRegistrations().then(function(registrations) {
for(let registration of registrations) {
registration.unregister();
} });</script>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…