A reload with a new version waiting never leaves the screen blank (#277, part 1) #309

Closed
kayg wants to merge 0 commits from issue/277-pwa-update into dev
Owner

Part 1 of #277: the pwa-update spec.

Verdict: the feature was broken in Chrome, and the test was right to fail. One assertion in the test was also stale.

What happened. Reload while a new version is waiting. The old service worker often serves the new page. Chrome then holds the takeover back until that old worker has been idle for 30 s. applyWaitingAtStartup waits for the takeover before it mounts anything, so the screen stayed blank the whole time. Measured in plain Chrome, with no DevTools attached to the worker (raw CDP on the page only): 3 of 6 reloads were blank for about 31 s. Playwright attaches DevTools to every worker, which keeps the old one running, so in the test the wait never ended (every run that reached it, 4 of 6 locally).

CDP traces of the stuck state: the waiting worker receives update-now, but its skipWaiting() never resolves. Stopping the old worker, or loading the page again, hands over at once.

Fix (pwa.svelte.ts). takeOver sends update-now once. If nothing has happened after 1 s, it reloads anyway: Chrome hands over at that page load because the new version has already asked to skip waiting. The existing 20 s guard still prevents loops. If the new version still isn't in charge, the app shows the current version. Plain Chrome after the fix: 8 of 8 reloads show the new version within 1.6 s. WebKit already worked (4/4 in a diagnostic run).

Spec.

  • It now runs in WebKit. That is the engine on the phone, and Playwright's DevTools don't keep the old worker alive there.
  • "unsaved typing is never swapped" asserts on data-save, because #139 removed the visible save text. That stale text check was why this test failed every time.
  • "signed out, a new version applies at once" is fixme: Playwright's WebKit can't route /api/v1/auth/status when the request passes through a service worker. The code path is unchanged.

Local: pwa-update + pwa specs, Chromium and WebKit, --repeat-each 3: 18 passed. Typecheck clean.

🤖 Generated with Claude Code

Part 1 of #277: the pwa-update spec. **Verdict: the feature was broken in Chrome, and the test was right to fail.** One assertion in the test was also stale. **What happened.** Reload while a new version is waiting. The old service worker often serves the new page. Chrome then holds the takeover back until that old worker has been idle for 30 s. `applyWaitingAtStartup` waits for the takeover before it mounts anything, so the screen stayed blank the whole time. Measured in plain Chrome, with no DevTools attached to the worker (raw CDP on the page only): **3 of 6 reloads were blank for about 31 s.** Playwright attaches DevTools to every worker, which keeps the old one running, so in the test the wait never ended (every run that reached it, 4 of 6 locally). CDP traces of the stuck state: the waiting worker receives `update-now`, but its `skipWaiting()` never resolves. Stopping the old worker, or loading the page again, hands over at once. **Fix (`pwa.svelte.ts`).** `takeOver` sends `update-now` once. If nothing has happened after 1 s, it reloads anyway: Chrome hands over at that page load because the new version has already asked to skip waiting. The existing 20 s guard still prevents loops. If the new version still isn't in charge, the app shows the current version. Plain Chrome after the fix: **8 of 8 reloads show the new version within 1.6 s.** WebKit already worked (4/4 in a diagnostic run). **Spec.** - It now runs in WebKit. That is the engine on the phone, and Playwright's DevTools don't keep the old worker alive there. - "unsaved typing is never swapped" asserts on `data-save`, because #139 removed the visible save text. That stale text check was why this test failed every time. - "signed out, a new version applies at once" is `fixme`: Playwright's WebKit can't route `/api/v1/auth/status` when the request passes through a service worker. The code path is unchanged. Local: pwa-update + pwa specs, Chromium and WebKit, `--repeat-each 3`: 18 passed. Typecheck clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A reload with a new version waiting never leaves the screen blank (#277)
Some checks failed
CI / server (pull_request) Successful in 21s
CI / web (pull_request) Failing after 23s
CI / rust (pull_request) Successful in 1m47s
a80ff1a11d
The feature was broken in Chrome, not only the test. After a reload
with a new version waiting, the old service worker often serves the new
page; Chrome then holds the takeover back until that worker has sat idle
for 30 s, and the app (which waits for the takeover at startup) showed
nothing all that time: 3 of 6 reloads in plain Chrome. Under Playwright,
which attaches DevTools to every worker, the wait never ended, which is
why the test failed every time it got that far.

Chrome hands over at the next page load once the new version has asked
to skip waiting, so the takeover now reloads after a second if nothing
happened. Plain Chrome: 8 of 8 reloads show the new version within
1.6 s. WebKit was already fine.

The spec runs in WebKit (Playwright's DevTools keep the old worker alive
in Chromium), asserts on data-save instead of the removed save text
(#139), and marks the signed-out test fixme: Playwright's WebKit can't
route requests that pass through a service worker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Author
Owner

Landed in merge train #332.

Landed in merge train #332.
kayg closed this pull request 2026-10-14 18:04:27 +00:00
Some checks failed
CI / server (pull_request) Successful in 21s
CI / web (pull_request) Failing after 23s
CI / rust (pull_request) Successful in 1m47s

Pull request closed

Sign in to join this conversation.
No reviewers
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!309
No description provided.