The old watchman and the new: install, waiting, skipWaiting and clients.claim() simulated on the spec’s rules. An interactive Service Worker Lifecycle…
Why it matters
The classic after-deploy problems: users still see the old version, a tab does not change controller, or a blank page because old chunks are gone. All of them follow the same lifecycle rules: when a worker waits, when it activates, whom it controls.
The key idea
A new worker waits until no tab is guarded by the old one
Common mistakes
Thinking a deploy means users get the new version at once Without skipWaiting(), the new worker waits in waiting until every tab of the site the old worker guards is closed. A plain reload is not enough.
Relying on skipWaiting() alone to move every tab over Tabs the old worker guarded do move to the new worker, but their page code stays old until a reload; a page with no controller yet (a first visit) is only taken by clients.claim() in activate.
Putting skipWaiting() in every app A swap mid-session makes the old page ask for old chunks that are gone (a chunk mismatch, a blank page). For a big app, offer "Update", then reload on controllerchange.
Try it in this playground
Release, then reload v2 keeps waiting, however often you reload.
Close every tab the old version guards Only then does v2 activate.
Turn on clients.claim(), then open a first tab The first visit is controlled at once.
skipWaiting() without a reload, then open another page The old chunk is gone: a blank page.