I work on Windows Pro 10 and use Workbox 6.x. As a test, in Chrome:
What I would like is the updated service worker get activated right away, but DevTools says it is waiting.
Documentation says that by default this will be added to the service worker:
self.addEventListener('message', event => { if (event.data && event.data.type === 'SKIP_WAITING') { self.skipWaiting(); }
I check and indeed the code is added,
Why then isn't skipWaiting doing the job?
Thanks,
Gilles Plante
Are you using workbox-build generateSW
to generate your service worker? Because by default skipWaiting
is set to false. You can check it here in the docstring , and here in the defaults .
If you just want to skip the service worker waiting
state when you are developing, you can enable Update on Reload in Chrome Dev Tools.
Also, be aware of the dangers of skipWaiting() .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.