Skip to content

Bound browser waits by the suite's deadlines, and every test by a half-hour limit - #1807

Merged
leaf-agent merged 1 commit into
mainfrom
agent-a672335f4c3635b27
Oct 5, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
agent-a672335f4c3635b27

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

#1778 moved Python-side waits onto STATED_TIMEOUT. Browser waits kept
literal millisecond deadlines sized to an unloaded run (to_have_text(..., timeout=10_000), wait_for_function(..., timeout=3000)), and every bare
expect kept Playwright's five-second default.

render_harness now makes SERVED_TIMEOUT_MS the default of every expect and
of every page it prepares, so a browser wait names a deadline only where it
spans a page handover (HANDOVER_DEADLINE_MS). Of the 72 literal browser
deadlines outside the files another change is rewriting, 38 hang bounds on one
fact drop their deadline, 32 waits across a replay, a reload or a restarted
server take HANDOVER_DEADLINE_MS, and two whose expiry is their subject name
their length. Three helpers lose a literal default deadline nothing overrode.

Three waits that depended on speed now wait on what the page states: the dead
release counts the replacement document's probe rounds instead of sleeping
four seconds, the probe-in-flight test holds the round until the page presents
instead of racing a two-second sleep against a 600 ms timer, and the read
receipt waits on wait_for instead of 100 polls of 20 ms.

test_a_wait_takes_the_suites_deadline replaces the Python-side check: any
timeout or timeout_ms a call passes or a helper defaults, a page's default
deadline, and the existing first-argument and monotonic() forms. It holds a
count per file for the six render files another change is rewriting.

test_widget_quality.py::test_an_export_first_paints_its_widgets_at_their_presented_boxes
hung until the six-hour job limit on two CI runs (37234497522, 37243845311).
No call in it can be bounded where it is made: page.evaluate and
browser.new_page take no deadline, and Playwright enforces the ones it takes
in its driver. pytest's faulthandler_timeout with exit now ends any test
still running after 30 minutes, printing every thread's stack, and xdist
reports it as crashed and carries on.

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

…f-hour limit

#1778 moved Python-side waits onto `STATED_TIMEOUT`. Browser waits kept
literal millisecond deadlines sized to an unloaded run (`to_have_text(...,
timeout=10_000)`, `wait_for_function(..., timeout=3000)`), and every bare
`expect` kept Playwright's five-second default.

`render_harness` now makes `SERVED_TIMEOUT_MS` the default of every `expect` and
of every page it prepares, so a browser wait names a deadline only where it
spans a page handover (`HANDOVER_DEADLINE_MS`). Of the 72 literal browser
deadlines outside the files another change is rewriting, 38 hang bounds on one
fact drop their deadline, 32 waits across a replay, a reload or a restarted
server take `HANDOVER_DEADLINE_MS`, and two whose expiry is their subject name
their length. Three helpers lose a literal default deadline nothing overrode.

Three waits that depended on speed now wait on what the page states: the dead
release counts the replacement document's probe rounds instead of sleeping
four seconds, the probe-in-flight test holds the round until the page presents
instead of racing a two-second sleep against a 600 ms timer, and the read
receipt waits on `wait_for` instead of 100 polls of 20 ms.

`test_a_wait_takes_the_suites_deadline` replaces the Python-side check: any
`timeout` or `timeout_ms` a call passes or a helper defaults, a page's default
deadline, and the existing first-argument and `monotonic()` forms. It holds a
count per file for the six render files another change is rewriting.

`test_widget_quality.py::test_an_export_first_paints_its_widgets_at_their_presented_boxes`
hung until the six-hour job limit on two CI runs (37234497522, 37243845311).
No call in it can be bounded where it is made: `page.evaluate` and
`browser.new_page` take no deadline, and Playwright enforces the ones it takes
in its driver. pytest's `faulthandler_timeout` with exit now ends any test
still running after 30 minutes, printing every thread's stack, and xdist
reports it as crashed and carries on.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@leaf-agent
leaf-agent merged commit c985b82 into main Oct 5, 2026
4 checks passed
@leaf-agent
leaf-agent deleted the agent-a672335f4c3635b27 branch October 5, 2026 08:02
max-sixty added a commit that referenced this pull request Oct 6, 2026
)

Two cuts to what the browser suite pays per test, from the cost survey
after #1807.

**A page server stops when asked**
(`skills/leaf/scripts/leaf/hosting.py`). Uvicorn notices `should_exit`
on a 0.1 s tick, then sleeps a fixed 0.1 s after asking each connection
to finish, so a page server with nothing in flight took ~0.18 s to stop,
and the suite stops one per browser test. `LeafHTTPServer` now runs a
uvicorn `Server` subclass whose loop also wakes on `shutdown()`, and
whose stop keeps uvicorn's order (close listeners, ask connections to
finish, wait for them and for running tasks, then for the servers) but
waits only as long as they take. Measured locally: a server stops in
0.001 s with its pages closed and 0.006 s with one still open (was 0.182
s); the drafts and reactions files' 225 teardowns sum to 3.9 s (was 35.9
s).

**CI runs three pytest workers** (`.github/workflows/ci.yaml`). The
runner's four vCPUs sat ~41% idle under two workers. In the Oct 4
experiment
([37211926233](https://github.com/max-sixty/leaf/actions/runs/37211926233))
four workers left 7% idle and cut wall time ~30% but slowed each test
1.3–1.46×; three take most of the idle share without saturating the
deadlines browser tests wait under. Local runs keep `pyproject.toml`'s
two, since several suites overlap on one machine. This adds no runners:
PR test jobs were 92 of the `ci` workflow's 155 runner-hours over the
last day, so a shorter job frees the shared pool directly.

Checked locally: `test_interact_server`, `test_website_server`,
`test_interact_session`, `test_interact_preview`, `test_interact_layer`,
`test_smoke` pass; `test_render_drafts` and `test_render_reactions`
(nightly) pass except the two reactions tests that fail identically on
main.

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[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.

2 participants