Skip to content

Fix update prompt not applying on reload#28

Merged
dubsector merged 1 commit into
mainfrom
fix-update-reload
Jul 7, 2026
Merged

Fix update prompt not applying on reload#28
dubsector merged 1 commit into
mainfrom
fix-update-reload

Conversation

@dubsector

Copy link
Copy Markdown
Owner

Summary

  • `registerType: 'prompt'` means vite-plugin-pwa never enables `clientsClaim` (that's only auto-set for `registerType: 'autoUpdate'`). Without it, clicking "Reload to update" called `skipWaiting()`, which activated the new worker, but never handed control of the already-open tab to it — so the `controllerchange` event the update flow waits on to reload never fired. The button looked broken on both desktop and mobile.
  • Restores the `SKIP_WAITING` message listener that the old `generateSW`-generated service worker used to add automatically, now that `sw.ts` is hand-written.

Test plan

  • Rebuilt, installed the fixed service worker fresh, forced a second build to simulate a new deploy, confirmed the update prompt appears and clicking "Reload to update" actually reloads to the new build (verified via build timestamp changing and DOM node IDs resetting after reload)

registerType is 'prompt', so vite-plugin-pwa never enables
clientsClaim (that only happens for registerType 'autoUpdate').
Without it, calling skipWaiting() activates the new worker but never
hands control of already-open tabs to it, so the controllerchange
event the update prompt waits on to reload never fires - the button
looked broken on both desktop and mobile.

Also restores the SKIP_WAITING message listener that generateSW used
to add automatically, now that sw.ts is hand-written.
@dubsector
dubsector merged commit f158c5c into main Jul 7, 2026
4 checks passed
@dubsector
dubsector deleted the fix-update-reload branch July 7, 2026 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant