mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-02 17:32:50 +08:00
Stop the service worker from stranding clients
Between48f5e35(07.09., registerType: 'autoUpdate') and5b5f4ca(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
This commit is contained in:
1 parent
06f38b4582
commit
2ee6d1f0b5
3 files changed
+183
-17
No files matched your search
Vendored
+3
@@ -1,3 +1,6 @@
|
||||
/// <reference types="vite/client" />
|
||||
/// <reference types="vite-plugin-pwa/client" />
|
||||
/// <reference types="vite-plugin-pwa/react" />
|
||||
|
||||
/** Injected by vite.config.ts; matches the `buildId` in version.json. */
|
||||
declare const __BUILD_ID__: string
|
||||
Reference in new issue
Block a user