Repository navigation
Bound browser waits by the suite's deadlines, and every test by a half-hour limit - #1807
Merged
Merged
Conversation
…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
approved these changes
Oct 5, 2026
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]>
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.
#1778 moved Python-side waits onto
STATED_TIMEOUT. Browser waits keptliteral millisecond deadlines sized to an unloaded run (
to_have_text(..., timeout=10_000),wait_for_function(..., timeout=3000)), and every bareexpectkept Playwright's five-second default.render_harnessnow makesSERVED_TIMEOUT_MSthe default of everyexpectandof 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 browserdeadlines 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 nametheir 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_forinstead of 100 polls of 20 ms.test_a_wait_takes_the_suites_deadlinereplaces the Python-side check: anytimeoutortimeout_msa call passes or a helper defaults, a page's defaultdeadline, and the existing first-argument and
monotonic()forms. It holds acount 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_boxeshung until the six-hour job limit on two CI runs (37234497522, 37243845311).
No call in it can be bounded where it is made:
page.evaluateandbrowser.new_pagetake no deadline, and Playwright enforces the ones it takesin its driver. pytest's
faulthandler_timeoutwith exit now ends any teststill running after 30 minutes, printing every thread's stack, and xdist
reports it as crashed and carries on.