skipWaiting() fails to activate waiting service worker
See original GitHub issueLibrary Affected: workbox-core v4.3.1
Browser & Platform: Windows: Google Chrome 78.0.3904.108, Firefox 71.0
Issue Description: I’ve tried to follow the instructions at the docs to show a prompt, when an update is available.
After clicking the button that triggers wb.messageSW({type: 'SKIP_WAITING'});
, the message is processed in the service worker, and skipWaiting()
is called. Then, a warning is logged to console in chrome:
Event handler of 'install' event must be added on the initial evaluation of worker script.
. The service worker
I’ve also tried to do a minimal reproduction of the bug, but there, it works as intended. Any idea whats going wrong in my project?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 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
skipWaiting() method of the ServiceWorkerGlobalScope forces the waiting service worker to become the active service worker.
Read more >Service worker and its self.skipWaiting() method
skipWaiting() method solves this problem by telling the newly installed service worker to skip the waiting state and move directly to activating ...
Read more >Service Workers - waitUntil, skipWaiting, and claim methods
This is the third video in the Understanding Service Workers Series.This video focuses on three very powerful methods that you can use ...
Read more >`skipWaiting()` with `StaleWhileRevalidate` the right way
To update the PWA app without leaving it, skipping the waiting phase of the new service worker is needed. Thus after location.reload() ......
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
As per the recipe, you need to make sure that your service worker includes
and not
workbox.skipWaiting()
for that to work. (TheskipWaiting()
in that example is effectivelyself.skipWaiting()
, andself
refers to theServiceWorkerGlobalScope
.)It’s a subtle difference, but
workbox.skipWaiting()
wraps the call inside of aninstall
handler, and while that’s suitable for use outside of amessage
event listener, inside the listener it ends up being executed after the initial evaluation of the worker script.@CalebKester sorry about that confusion. In v6, we’ve deprecated usage of
skipWaiting()
fromworkbox-core
because of that sort of frustration.https://github.com/GoogleChrome/workbox/blob/6d38919ebbc9664327e19ff00302d805c8166170/packages/workbox-core/src/skipWaiting.ts#L16-L33