Skip to content

fix(editor): re-request the frame's document when a worker swap killed it - #228

Merged
chaxus merged 1 commit into
mainfrom
fix/blank-editor-frame-watchdog
Sep 12, 2026
Merged

chaxus merged 1 commit into
mainfrom
fix/blank-editor-frame-watchdog

Conversation

@chaxus

@chaxus chaxus commented Sep 12, 2026

Copy link
Copy Markdown
Member

main has been red on sw-silent-update since #224. The trace from the failing CI job says what happens:

  • every request 200, except the vendored editor's own iframe document, which ends at status -1
  • no console error, no onAppReady, white screenshot

Activating a Service Worker terminates the outgoing one and fails every request it still had in flight. lib/sw-update.ts covers the swap a page sees as a controllerchange; it cannot cover the one where the page already started under the new controller and the casualty is a request made afterwards. Nothing retries that frame, so the reader is left on a blank page with no way out but a manual reload — the exact failure mode docs/explorations/2026-08-23-promotion-without-reload-blank-editor.md describes, arriving by a route that mitigation does not see.

The watchdog

If the frame has said nothing after 25 s and is empty, ask for its document again. There is no editor state to lose — the editor never started. Once, not forever: a second silence is not a lost request.

The window is long on purpose. An aborted navigation and one still in flight look identical from outside (the frame keeps its about:blank document either way), so only time separates them. settleEditor gives the whole boot 90 s, which leaves room for the retried load.

On verification

Not reproducible locally — four repeats of the failing case and an 8× CPU-throttled run all settle in 14 s. So the decision logic is unit-tested directly (5 cases: retries an empty silent frame, stands down on ready, leaves a rendered frame alone, leaves a frame still loading alone, retries once and not forever) and CI is what confirms the rest.

If sw-silent-update still fails after this, the watchdog was not enough and the next step is instrumenting that transition rather than widening timeouts — which is what #227 tried, and it timed out at 180 s too.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MKNHFQ1kek1cHeqhbH37Pk

…d it

main has been red on sw-silent-update since the x2t worker landed, and
the trace says what happens: every request 200 except the vendored
editor's own iframe document, which ends at status -1, no console error,
no onAppReady, and a white screenshot.

Activating a Service Worker terminates the outgoing one and fails every
request it still had in flight. lib/sw-update.ts covers the swap a page
sees as a controllerchange; it cannot cover the one where the page
already started under the new controller and the casualty is a request
made afterwards. Nothing retries that frame, so the reader is left on a
blank page with no way out but a manual reload.

The watchdog asks for the document again if the frame has said nothing
after 25 s and is empty. There is no editor state to lose -- the editor
never started. Once, not forever: a second silence is not a lost request.

The window is long on purpose. An aborted navigation and one still in
flight look identical from outside (the frame keeps its about:blank
document either way), so only time separates them; settleEditor gives the
whole boot 90 s, which leaves room for the retried load.

Not reproducible locally -- four repeats and 8x CPU throttling all settle
in 14 s -- so the decision logic is unit-tested directly and CI is what
confirms the rest.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MKNHFQ1kek1cHeqhbH37Pk
@chaxus
chaxus enabled auto-merge (rebase) September 12, 2026 10:55
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying document with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6dd8dba
Status: ✅  Deploy successful!
Preview URL: https://02a9d81d.document-7hm.pages.dev
Branch Preview URL: https://fix-blank-editor-frame-watch.document-7hm.pages.dev

View logs

@chaxus
chaxus merged commit 174a19a into main Sep 12, 2026
18 checks passed
@chaxus
chaxus deleted the fix/blank-editor-frame-watchdog branch September 12, 2026 11:02
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