Skip to content

Ask the server once more for a page whose module failed to load while it still answers - #6154

Merged
max-sixty merged 2 commits into
mainfrom
startup-reload-after-failed-load
Nov 16, 2026
Merged

max-sixty merged 2 commits into
mainfrom
startup-reload-after-failed-load

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

A served page whose runtime module failed to load never started, even when its server answered again a moment later. The startup supervisor in bootstrap.js probed the server every second and reloaded only when the server, layer or release changed, and a browser keeps a failed module fetch for the document's life. A page that lost one module to a network change (net::ERR_NETWORK_CHANGED, which the macOS runner hit in two workers at once) sat under "Leaf couldn't start. Waiting for Leaf to update." for good.

Now a page that is incomplete reloads once, marked _leaf-recovered, when the probe answers OK from the same server. Prepaint already records incompleteness by taking data-lf-interactive off the root for every fault where something the page needs didn't arrive, and the supervisor reads that when it acts, so an incomplete fault after an uncaught error counts too. A marked document that fails again waits for a new server as before, so a module that fails every time costs one extra load and never loops. The ask marks the address and reloads, as a revision's handoff does; the dead-release ask takes the same path. A page that has upgraded and is still whole is never navigated; one that upgraded without its theme is incomplete, so it asks too.

What to weigh: a deterministic failure, such as a 404 module or a boot TypeError, now loads the page twice before the notice stays. Telling it from a transient one needs the failed URL, which a module script's error event doesn't give. Tests about how a page that cannot start looks now open the marked address (asked_again), so they read one document instead of racing its replacement.

Max asked for this fix after a CPU-starved run exposed it. A subagent reviewed it twice and the review bot once; their findings (reload rather than replace, incompleteness read when acting, one test of a started page for both the entry read and the observer) are in.

Tests: the new test fails a runtime module once (the page starts on its second document), every time (one replacement, then the probe's cadence), and the theme together with the first probe (the page upgrades incomplete, then asks). Under taskpolicy -b with 18 busy loops, the two module cases failed 2 of 2 runs on main, and all three cases passed 3 of 3 runs on this branch. The startup-failure tests, sample-failure journeys and site recovery journeys pass, as do pnpm run check and pnpm run test:runtime. leaf-dev probe triage-board --base shows the same 291 requests before the page presents, and 81 more document bytes.

This was written by Claude Code on behalf of max-sixty

… it still answers

A served page whose runtime module failed to load never started, even when its server answered again a moment later. The bootstrap's startup supervisor probed the server every second and reloaded only when the server, layer or release changed, and a browser keeps a failed module fetch for the document's life. A page that lost one module to a network change (`net::ERR_NETWORK_CHANGED`, seen on the macOS runner) stayed under "Leaf couldn't start. Waiting for Leaf to update." for good.

Now a page that is incomplete, which prepaint marks by taking `data-lf-interactive` off the root for every fault where something it needs did not arrive, reloads once, marked `_leaf-recovered`, when the probe answers OK from the same server. The supervisor reads that mark when it acts, so an incomplete fault that follows an uncaught error counts too, and the fault event no longer carries `incomplete`. A marked document that fails again waits for a new server as before, so a module that fails every time costs one extra load and never loops. The ask marks the address and reloads, as a revision's handoff does, so the revision handoff and scroll restoration survive it; the dead-release ask now takes the same path. A page that has upgraded and is still whole counts as started whenever its fault arrives, and one that upgrades after the fault, as it can without its theme, drops its notice; neither is navigated. A page whose runtime declared it failed after upgrading shows its readable fallback, so it asks.

Tests about how a page that cannot start stands open the marked address (`asked_again`), so they read one document instead of racing its replacement. A new test fails a runtime module once (the page starts on its second document) and every time (one replacement, then the probe's cadence).

> _This was written by Claude Code on behalf of max-sixty_

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A page that upgrades while incomplete now drops its notice and stops recovering, which works against the fix in the case it targets. The upgrade observer used to be installed only for faults that left the page whole (!awaits). It is now installed for every fault, and it sets started on data-lf-upgraded alone, while the initial started also requires data-lf-interactive. A missing theme is incomplete but still lets boot() reach markPageUpgraded(). So when the theme fails and the page upgrades before a probe answers OK, the observer sets started: the notice goes, check stops, and the page never asks again. It also no longer reloads when a new server arrives. A network change that kills the theme request and the first probe together produces exactly that ordering.

I checked this on a marked document whose theme.css is aborted. On this head the page ends with data-lf-upgraded, no data-lf-interactive, data-lf-startup-error="theme stylesheet did not load", and no notice. With main's bootstrap.js/prepaint.js the notice stays and the page keeps waiting for a new server.

The suggestion below makes the observer use the same predicate as the initial started. If you do mean an upgraded page without its theme to count as started, the initial expression should drop its data-lf-interactive check instead. Either way the two need to agree, and the comment above them ("as one can whose theme did not arrive") should follow whichever you choose.

Comment thread browser/runtime/bootstrap.js Resolved
The upgrade observer set `started` on `data-lf-upgraded` alone, while the start it read on entry also asked for `data-lf-interactive`. A page whose theme failed to load still upgrades, so when it upgraded before a probe answered, the observer dropped the notice and stopped recovery: the page never asked its server again, nor reloaded for a new one. Both now ask the same question, and the new test covers a theme lost together with the first probe, which fails on the previous commit and passes here.

> _This was written by Claude Code on behalf of max-sixty_
@max-sixty
max-sixty merged commit 200df53 into main Nov 16, 2026
6 checks passed
@max-sixty
max-sixty deleted the startup-reload-after-failed-load branch November 16, 2026 09:57
leaf-agent added a commit that referenced this pull request Nov 16, 2026
#6187)

Since #6154, a page whose module fails to load reloads itself once from
the same server at an address marked `_leaf-recovered`. `page check` and
`page check --render` kept reading the first document after it refused
(waiting for its reports to be acknowledged), so the reload destroyed it
under them. Plain `page check` returned a `browser-error` ("Execution
context was destroyed") in place of its reading, and the render check's
page-code reading came back empty, so **`page check --render` passed a
page that could not start**. Both now open the page at the marked
address, where a page that cannot start waits for a new server instead
of reloading, so each reads exactly one document — the same address
#6154 gave the startup tests (`asked_again`, now moved from
`tests/render_harness.py` into `leaf.render_checks` so the check and the
tests share it). `wait_until_ready`'s `fixed_server` docstring now says
its callers open the page there.


`tests/journeys/test_render_commands.py::test_plain_check_reports_page_request_failures_but_ignores_optional_assets`
fails on main (`assert [] == [page-report, not-ready, browser-error,
…]`) and passes on this branch. Its `browser-error` finding is gone,
since the plain check no longer races the reload.

Two findings now show a different address:

- A request finding's `frame` is the address the frame shows once the
bootstrap has removed its marks and the host key
(`Page.navigatedWithinDocument`). Before, it was the address the check
asked for. The journey test now expects the address without `?t=…`.
- When the server refuses the document itself, the console finding names
the marked address the check requested, because no bootstrap ran to
rewrite it.
`test_a_refused_document_reports_its_status_with_the_gate_failure` now
expects `asked_again(refused)`.

A check no longer gets #6154's single retry after a transient module
failure. That matches how the check behaved before #6154, and its
reading stays deterministic.

<details><summary>Verification</summary>

Passing locally: the reproduced journey test above, the other
plain/render check journeys in the same file
(`test_plain_check_runs_the_code_a_page_authored`, `…_reads_media`,
`test_a_widget_that_fails_in_a_message_…`,
`test_a_passing_render_check_…`,
`test_render_reads_widget_chrome_where_it_stands`), every `asked_again`
caller in `tests/browser/` (startup keys/readiness, initial delivery,
render pages), `test_render_gate.py`'s unanswered-resource,
refused-document and far-sample gate tests, and the smoke test's
shipped-page gate.

`test_check_render_refuses_what_only_a_browser_can_see` fails here with
`assert None == 'Chrome'` both on this branch and on main without it,
because this runner has no browser named Chrome.

</details>

Closes #6180 — automated triage

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Nov 16, 2026
…ved Firefox (#6197)

Max's direction for tests whose result depends on CPU: design them so it
can't, confirm that in the nightly runs, and keep starved runs out of
the merge pipeline. This makes the macOS nightly that run: it now uses
four workers on the runner's three cores, which starves every test. A
trial at four workers ([run
43780587059](https://github.com/max-sixty/leaf/actions/runs/43780587059))
took 4h11m against 4h12m at two, with the CPU at 0% idle throughout and
memory peaking at 7.1 of 7.5 GB, no swap. `tests/AGENTS.md` now names
that job as the slow-machine rule's check.

In a starved Firefox, PageUp in a live log can do nothing: Firefox
applies the key's scroll 280–800 ms late, after the reader's 80 ms wait
for it, and no event says the browser won't scroll, so ending the loss
needs a deadline. Max accepted it as a corner case, so the Firefox cases
of `test_a_page_up_in_a_log_a_stream_feeds_leaves_its_end` whose scroll
the browser applies (PageUp, PageUp on a link, wheel, wheel across) are
now non-strict expected failures; this PR's first CI run lost a wheel
the same way. They pass at normal load, as they did locally here and on
main's last three push runs. `u`, which Leaf's own glide scrolls, stays
a plain case.

To weigh: the trial run at four workers had 30 failures against 21 at
two. #6154, #6155, #6166 and #6169 fixed the load-dependent ones found
then, but the first nightly after this may still turn up more; each is a
test whose result depends on speed.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 18, 2026
…e tools and ten tests they caught (#6412)

Nothing in CI ran `dev/tests`, so main commits broke those tests without
anyone seeing (#6374 fixed ten of them). This adds every developer-tool
test, the Python and the Node ones, to the daily scheduled run, after
the product suite, where a failure reaches Tend like any other failure
on main. Pull requests, pushes to main and landing gates still don't run
them. On the Ubuntu runner they took 8 minutes 43 seconds (235 passed,
and the one macOS-only test skipped).

Three of the 13 other failures were tools that had stopped working:

- `leaf-dev preview` kept serving the runtime and layer its process
first read, so an edit to `browser/leaf.js`, `browser/base.css` or a
bundled package reached neither an open tab nor a fresh one. It also
decided when to restart from its own copy of the runtime's identity,
which had lost the kernel's stylesheets and the bundled packages, so
editing those never restarted even a `--user` preview's server. The
preview now reads the runtime's own identity, and replacing its
in-process server first drops what the process holds of the tree
(`runtime_selection.forget_tree`, which is new).
- `leaf-dev site demo` stopped getting a title for its thread after
#5835, because its own session has no hooks module to answer the
request. It now answers with a staged title through the suite's stand-in
for that module, which moves to `leaf_dev.claude_code_module`.
- `leaf-dev trace-server` called a Playwright export that 1.65 removed.

The other ten had stale expectations: #5964's stdout refusals, #4325's
recovery words, #6154's recovery reload, the layer record's dropped
`fingerprint`, and a preview identity that moved to About this page. Two
more tests started a second Playwright driver on a worker thread that
already held one.

To weigh: the demo's thread title is now the same every run, rather than
worded fresh by a model each time.

Asked for by max-sixty, as a follow-up to #6374. Tests: all of
`dev/tests` locally and, through a commit since reverted, on this PR's
runner; the product modules the stand-in move and the layer change touch
(225 passed).

> _This was written by Claude Code on behalf of max-sixty_
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.

2 participants