Between 48f5e35 (07.09., registerType: 'autoUpdate') and 5b5f4ca (10.09.,
switched to 'prompt') every client that cached the app froze: the new
worker sits in `waiting` and the only code that could release it - the
update toast - lives in the build behind that worker. Their next update
never arrives, and Pages deletes the hashed assets they still run from,
so the bundle they serve does not exist on the server any more. That is
how the feedback form went missing on client.webspeak3.de.
- Back to 'autoUpdate', with skipWaiting/clientsClaim spelled out: the
plugin only sets them when it also injects registerSW.js, so with
injectRegister: false the generated worker was byte-identical to the
'prompt' one. Verified in dist/sw.js.
- onNeedReload instead of onNeedRefresh: the worker takes over on its
own, the toast only decides *when* to reload, so nobody is thrown out
of a running connection.
- version.json plus a __BUILD_ID__ baked into the bundle, checked every
30 min and on tab focus, deliberately routed around the worker (not in
globPatterns, so never precached). If the server is on another build
and no new worker turns up, the worker is wedged and the button clears
registrations and caches instead of reloading into the same cache.
- Dismissing the toast snoozes for 30 min rather than for good.
Verified in headless Chromium against simulated deploys: a client stuck
on the old worker lands on the new bundle at the first plain F5.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
Previously the service worker used registerType: 'autoUpdate' with
the default injected register script - a new deploy would install
and activate a new SW in the background, but an already-open tab
kept running the old JS/CSS from memory with no indication a newer
version existed, short of a manual hard reload (or clearing SW/
caches by hand, which we had to do repeatedly while verifying
deploys this session).
Switch to registerType: 'prompt' and register the SW ourselves via
virtual:pwa-register/react (useRegisterSW), showing a small "new
version available" toast with a reload button when an update is
waiting. Also poll registration.update() hourly so long-lived tabs
notice updates without needing a fresh navigation.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>