Service worker skipWaiting not activating workbox service worker
See original GitHub issueLibrary Affected: workbox-sw.
Browser & Platform: All
Issue or Feature Request Description:
*I have migrated from SW-Precache to workbox service worker, and during the process, I’ve updated service worker filename from ‘service-worker.js’ to ‘service-worker-mobile.js’ and also added workbox.skipWaiting()
in the new service worker file, implying that as soon as new service worker file is downloaded, and installed, it should get activated, but, I can still see my old service worker file running. Any help here? *
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Service Worker skipWaiting unable to activate currently ...
The 'waiting' state cannot be found in the typescript definitions: type ServiceWorkerState = "installing" | "installed" | "activating" | " ...
Read more >ServiceWorkerGlobalScope.skipWaiting() - Web APIs | MDN
The ServiceWorkerGlobalScope.skipWaiting() method of the ServiceWorkerGlobalScope forces the waiting service worker to become the active ...
Read more >`skipWaiting()` with `StaleWhileRevalidate` the right way
skipWaiting () may not work properly. ... By default, a service worker takes over the page from start to end, even if the...
Read more >Service worker and its self.skipWaiting() method
The ServiceWorker. skipWaiting() method solves this problem by telling the newly installed service worker to skip the waiting state and move ...
Read more >Handling Service Worker updates – how to keep the app ...
Not applying the Service Worker update might mean that our outdated Service ... skipWaiting() from within the new Service Worker – it immediately...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
By the way,
workbox-window
v6 has a new helper method,messageSkipWaiting()
, that can be used from a web page client and will always usepostMessage({type: 'SKIP_WAITING'})
to the correct service,waiting
service worker instance.If anyone googles this issue 👆 and gets here, this happens when you call
self.skipWaiting
on the already activated (i.e. old) service worker instead of the installed and waiting (i.e. new) service worker.AFAIK it is not possible to activate the newly installed service worker from within the old one, but you can send the new service worker a message from the old one like so:
However, you probably want to send this message from a client (i.e. a web page) instead. In this case make sure you are sending the correct registartion the message.