fix(sw): do not let a busy worker's silence cancel the reload that repairs a torn page - #204
Merged
Conversation
…pairs a torn page A blank editor in CI, on the silent-heal case. The trace says the controller did change (the test's own three-second VERSION question to the new worker was answered), the third editor boot started and died before a single guard installed -- and no fourth boot ever began. The reload that repairs a page the swap tore in half never happened. What cancelled it was the one-second question in isUnseenBuild. A worker answers VERSION from its message handler, which it cannot run while it is busy, and it is busiest in exactly that moment: just activated, terminating the worker it replaced, with the page refetching a vendor tree it has not cached. The silence was read as "nothing new", so isNewBuild came back false and the tab stayed blank until the test gave up. This file already learned that lesson once -- "a worker under load does not answer within a timeout" -- but on the promotion side, which was moved to cache evidence. The controllerchange side kept asking, and here a wrong answer is not a wasted reload: it is a white page with no way out but a manual one. So: askVersionPatiently, three tries of two seconds. Silence still decides, it just cannot decide early. Not the judgement conditions, deliberately. "Is a document open" is already known to be the wrong one, and "unsaved changes" was not the cause -- the boot that died was a fresh page load with the dirty flag false. Not cache evidence either: a page torn mid-boot may not have completed one vendor request, so the incoming build has no runtime cache to be seen by. Reverse-verified: with askVersion back in place, exactly one of the new cases fails and the other 52 pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
chaxus
enabled auto-merge (rebase)
August 23, 2026 16:01
Deploying document with
|
| Latest commit: |
68a2426
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://d00b0333.document-7hm.pages.dev |
| Branch Preview URL: | https://sw-version-patience.document-7hm.pages.dev |
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.
The failure
sw-silent-update.spec.ts(the@serialbatch) failed once on main with a completely white page. It passed on rerun, so it is intermittent — but the trace says what happened, and it is not a test problem.From the trace:
Creating new editor instanceappears three times,Document loadedtwice. After the third boot, not one of the twelve[OO] …guard lines appears — it died beforeonAppReady, i.e. before any of our patch code ran.vendorVersion === 'e2e-next'passed (the failure is on the next line,settleEditor). So the controller did change, and the new worker did answer a three-second question.What cancelled the reload
shouldReloadOnControllerChangeneedsisNewBuild, which comes fromisUnseenBuild, which opens with:A worker answers
VERSIONfrom its message handler, which it cannot run while it is busy — and it is busiest in precisely that moment: just activated, terminating the worker it replaced, with the page refetching a vendor tree that is not in its cache. One second of silence became "nothing new to tell you", so the page did not reload.This file already learned that lesson once ("a worker under load does not answer within a timeout, silence got read as 'it is old'") — but on the promotion side, which was then moved to cache evidence. The
controllerchangeside kept asking. The asymmetry matters: there, a wrong answer costs a wasted reload; here it costs a white page with no way out but a manual reload.The change
askVersionPatiently()— three tries of two seconds — used byisUnseenBuild. Silence still decides; it just cannot decide early.Deliberately not:
Tests
Three new cases in
test/unit/sw-update.test.ts, on fake timers so they cost no wall clock: a busy worker that drops the first question is still identified as a new build; a worker that never answers still falls back to doing nothing; and the default budget is at least three seconds. The existing "does not answer" case moves to fake timers too — giving up now takes six seconds and would blow the 5 s per-test default.Reverse-verified: with
askVersionput back, exactly one case (keeps asking a worker that was too busy…) fails and the other 52 pass; restored, 53 pass. Locally: 2700 unit tests, andsw-silent-update+sw-warmE2E green.Known gap
The CI failure was intermittent, so there is no E2E that reproduces it on demand — pinning it would need a hook to make a worker too busy to answer, which does not exist. The unit cases pin the decision logic; the white-page path itself is still guarded only by
sw-silent-update.Write-up:
docs/explorations/2026-08-24-sw-version-question-timeout.md.