Skip to content

fix: report faults after native document removal settles - #4966

Merged
leaf-agent merged 1 commit into
mainfrom
fix/issue-4906
Nov 1, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
fix/issue-4906

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

Iframe removal can reject a sample's pending registry fetch before pagehide or window.closed marks its document as departed. The shared fault lifetime then reports that cancellation as a startup failure. Fault reports now read the lifetime in the next task, after native removal finishes. Each queued report retains its departure generation so a page-cache return cannot revive a canceled report.

This preserves #3280's intent: genuine faults still reach the agent, while a departing document's canceled work does not. Sample retirement still destroys the old realm before releasing its capability. No error-message filtering or sample-specific exception suppression is added.

Validation: all three reported sample paths failed on the original code and pass with the correction, including the deliberate startup exception's original name and stack. Twelve focused browser cases pass across sample reset/retirement, reload, Chromium/WebKit native departure, canceled departure, startup faults and Firefox departure. All 737 runtime tests and the browser build pass. The lifetime regression also fails against the original prepaint and passes with the fix; it covers rejection before pagehide and queued cancellation across a page-cache return. The canceled-navigation test now waits for both the native exception and Leaf's deferred report.

Closes #4906 — automated triage

Iframe removal can reject a pending registry fetch before pagehide or window.closed ends the child lifetime. Classify reports in the next task and retain their departure generation so a page-cache return cannot revive a canceled report. Live faults still report, with native exceptions and deferred Leaf reports consumed together by the canceled-navigation check.

Closes #4906
@leaf-agent
leaf-agent merged commit 99eb211 into main Nov 1, 2026
5 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-4906 branch November 1, 2026 17:29
leaf-agent added a commit that referenced this pull request Nov 2, 2026
The reconnect test read browser errors before the second failure's
console report arrived. #4966 intentionally deferred fault reporting
until after the native operation, so removing an iframe does not report
its canceled requests as page failures; presentation completion no
longer implies console delivery.

Wait for the matching console event around each deliberate failed draw.
The existing assertions still require two failures, two reports, a
reconnect repaint, and no pending presentation work. No product behavior
changes.

Validation: the focused
`test_a_returning_widget_repaints_to_restore_subscriptions` failed
before this change with the reported one-versus-two mismatch and passes
afterward (`uv run pytest
tests/browser/test_render_application_boundary.py::test_a_returning_widget_repaints_to_restore_subscriptions
-q -n0`). Formatting and `git diff --check` pass.

Closes #5094 — automated triage

Co-authored-by: leaf-agent <[email protected]>
max-sixty pushed a commit that referenced this pull request Nov 4, 2026
…rs (#5312)

`test_widget_controller_owns_presentation_across_values_and_lifetimes`
intermittently read no browser errors on the scheduled macOS job ([run
41432142330](https://github.com/max-sixty/leaf/actions/runs/41432142330)
for `light` and `shadow-child`, [run
41622727492](https://github.com/max-sixty/leaf/actions/runs/41622727492)
for `shadow-host`), where it expected the deliberate render failure's
`leaf:` report. Since #4966, `reportPageError` writes that report
through `lfDocumentLifetime.whenActive`, a task after the fault, so a
removed iframe's cancelled requests don't read as page failures. The
error box and a settled presentation therefore no longer mean the
console has the report, and a test that reads `take_browser_errors`
right away races it.

Five browser tests read a `leaf:` report this way. They now call
`reported_browser_errors`, the harness's existing wait for a named
inventory of browser problems, which still requires exactly the reports
each test expects (one each, two for the returning widget). The
returning-widget test's ad hoc `expect_console_message` wrappers from
#5108, which fixed the same race there, are replaced by the same call.
No product behavior changes.

Verification: with every `leaf:` console report held 300 ms in
`layer-client.js` (a local experiment, not committed), five of the seven
focused cases fail on the old tests with the reported `[] == [...]`
diagnostic, and all seven pass on the new tests, with and without the
delay:

```
tests/browser/test_render_application_boundary.py::test_a_returning_widget_repaints_to_restore_subscriptions
tests/browser/test_render_application_boundary.py::test_widget_controller_owns_presentation_across_values_and_lifetimes  (3 cases)
tests/browser/test_render_application_boundary.py::test_thread_presentation_waits_for_its_frozen_widgets_only
tests/browser/navigation/test_obligation_walk.py::test_a_failed_obligation_reveal_does_not_register_an_arrival
tests/browser/test_render_outbox.py::test_an_optimistic_presentation_fault_does_not_change_delivery_result
```

Closes #5189 — automated triage

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Nov 4, 2026
…d state answers and deferred fault reports (#5334)

Every test in #5070 fails on main because three merged changes moved
contracts these tests still read the old way. Each repair updates only
the test, to the behavior its change intended. None moves product
behavior.

- **Control+Alt+r never pressed Latest (14 tests, plus the journey in
#5070's comment).** The test page's script listens for Control+Alt+r on
`window` and clicks the panel's Latest row notice. #5037 stops keys
typed into a Leaf field at the field so a page's bubble listeners never
hear them; its contract (`field-keys.js`) keeps capture listeners
hearing them. With an editor focused, the hook never ran, the revision
stayed deferred behind the composition, and `wait_for_revision(page, 2)`
timed out. The hook now listens in capture. Bisect: the composer case
passes at `1c38e1070` and times out at `8a4e213d0` (#5037).
-
**`test_a_mechanical_revision_failure_leaves_accepted_publication_ready`.**
It began as `StopIteration`, from the same missing press. With the press
fixed, it raised `KeyError: 'reading'`, because #5307 answers a tab that
names its held reading with a patch. The test now reads the new
reading's name from the patch's `["reading"]` change.
-
**`test_a_fresh_revision_caret_failure_does_not_strand_deferred_arrivals`.**
This one had a separate cause and was failing before #5037 with `assert
([])`. Bisecting over `7c1e4494ac..9a142d1` points to #4966, which
reports a fault in the next task. The test took the errors as soon as
the revision installed, so it now waits for the report with
`reported_browser_errors`.

Verification: all 16 tests listed in #5070 and
`tests/journeys/test_render_drafts.py::test_executable_revision_does_not_restore_a_new_draft_generation`
pass locally on this head (29 passed across `test_revisions.py` and the
two named tests). Before the change, the composer case failed on main
after its 120 s timeout.

Closes #5070 — automated triage

Co-authored-by: leaf-agent <[email protected]>
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.

Sample reset reports a startup fetch failure during teardown

1 participant