fix(pwa): promote waiting SW + periodic update checks so releases land#112
Merged
Conversation
The installed PWA could keep serving an old build: the updater only checked for a new SW on load/focus and only reacted to controllerchange, so a worker stuck in "waiting" never took over. Now the page actively messages waiting/installed workers to skip waiting (handled by a new SW message listener), watches updatefound, and re-checks on an interval — then reloads when the new worker controls the page. Verified the SKIP_WAITING handler ships in the built sw.js. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A user's installed PWA kept showing an old build (the pre-fix PIN screen) even after close/reopen — the deployed code was correct (works in-browser), but the home-screen app's service worker wasn't taking over.
The existing updater only reacted to
controllerchangeand checked on load/focus. A worker stuck in "waiting" never activated, so the old bundle kept being served.Now the updater:
postMessage({type:"SKIP_WAITING"}), handled by a newmessagelistener inapp/sw.ts),updatefound→installedand promotes,Verified the
SKIP_WAITINGhandler ships in the builtsw.jsand the prod build (incl. SW bundling) succeeds.Caveat (not code-fixable): iOS only refreshes a home-screen PWA's icon on reinstall, and an install whose SW predates the auto-updater (shipped #50, Jun 23) may need a one-time remove-and-re-add to recover.
🤖 Generated with Claude Code