PWA: a new version never reaches a reloaded tab (stuck waiting) #132

Closed
opened 2026-10-14 05:06:19 +00:00 by kayg · 0 comments
Owner

kayg reloaded next.calternal.cloud on an iPhone after the #105 deploy and still saw the old sign-in screen (card low, beige bands). The server serves the new build. The service worker (apps/web/sw/sw.js, src/lib/pwa.svelte.ts) keeps a new version waiting until no tab of the old one is left. A Safari reload never leaves that state, and the only way to apply it, "Update now", sits in Settings, which a signed-out person can't reach. So a deploy can stay invisible indefinitely.

Fix, keeping the rule "never swap code under someone typing":

  • At startup, before mount: if a version is waiting, activate it and reload once. Nothing has been typed yet. Guard against reload loops.
  • When nobody can be typing: a new version found while signed out (sign-in or setup screen), or while no note is open and nothing is pending, applies at once.
  • While a note is open: keep the quiet "Update ready" offer. Also apply the update the next time the app comes back from the background with nothing pending, because iOS rarely fully closes a tab.
  • Tests: Playwright for each case, including "a reload after a deploy shows the new version" and "an open note with unsaved typing is never swapped".
kayg reloaded next.calternal.cloud on an iPhone after the #105 deploy and still saw the old sign-in screen (card low, beige bands). The server serves the new build. The service worker (`apps/web/sw/sw.js`, `src/lib/pwa.svelte.ts`) keeps a new version **waiting** until no tab of the old one is left. A Safari reload never leaves that state, and the only way to apply it, "Update now", sits in Settings, which a signed-out person can't reach. So a deploy can stay invisible indefinitely. Fix, keeping the rule "never swap code under someone typing": - **At startup, before mount:** if a version is waiting, activate it and reload once. Nothing has been typed yet. Guard against reload loops. - **When nobody can be typing:** a new version found while signed out (sign-in or setup screen), or while no note is open and nothing is pending, applies at once. - **While a note is open:** keep the quiet "Update ready" offer. Also apply the update the next time the app comes back from the background with nothing pending, because iOS rarely fully closes a tab. - **Tests:** Playwright for each case, including "a reload after a deploy shows the new version" and "an open note with unsaved typing is never swapped".
kayg closed this issue 2026-10-14 06:50:37 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal#132
No description provided.