Search code examples
service-workerprogressive-web-apps

Does ServiceWorkerRegistration.update() skip waiting phase and activate the new service worker?


I was reading NekR/offline-plugin source code. In the update method it calls browser's ServiceWorker.update().

I want to know that if this method force activate the new service worker(i.e. skipWaiting) or it just pull the latest service worker and waiting for user to detach service workers from browser(i.e. waiting phase).


Solution

  • No, it does not force the new SW to take control. That could potentially break many applications. Install event is executed and the SW script itself is responsible for calling skipWaiting etc. if it wants to.

    You can see that from the spesification of the Service Worker update process. SkipWaiting is not scheduled. https://www.w3.org/TR/service-workers-1/#dom-serviceworkerregistration-update