Skip to content

Fix browser timeout lifecycle boundaries - #102

Merged
max-sixty merged 2 commits into
mainfrom
codex/fix-timeout-root-causes
Aug 29, 2026
Merged

max-sixty merged 2 commits into
mainfrom
codex/fix-timeout-root-causes

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

PR #100 bounded probe promises so CI named a stopped probe, but the operations and their deadlines still lived inside the page. This change removes the underlying waits: shipped probes publish synchronous readings or readiness facts, module and frame progress is observed through Playwright's bounded driver waits, and redundant per-holder animation waits are gone.

It also closes the two lifecycle races exposed by PR #100's own CI: complete-revision waits now include the server reading applied to that document, and response-transforming route handlers are drained before their page is disposed. The remaining image-event wait follows the same publish-and-poll pattern.

Tests: uv run pytest tests --run-nightly -q (1484 passed, 1 skipped); uv run pre-commit run --all-files.

This was written by Codex 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.

The probe-lifecycle rework itself reads well — no async export is left under render-checks/, nextFrame has no remaining callers, and the driver-side refusal of a thenable probe is a good place to put the invariant. One blocker, reproduced.

The two new gate tests fail under the repo's default -n 2. Both were dropped to served_timeout_ms=500, but that value is not just the probe deadline — _render_scheme passes it straight into served_here, so it is also the page.request.get deadline for /registry.json, /api/state, the markup, and the previous stamp. Both tests deliberately need the whole gate to run before reaching the probe they stub (the docstring of the test being replaced said so: "the readings before this one have to run for the gate to reach a probe at all"), so under any concurrency the served fetch trips first and the assert all(...) breaks on an unrelated finding:

FAILED tests/test_render_gate.py::test_an_async_reading_probe_is_refused_instead_of_awaited
  AssertionError: an async reading has to name itself, and this came back as
  ['[light] the server stopped answering: APIRequestContext.get: Timeout 500ms exceeded.',
   '[dark] the server stopped answering: APIRequestContext.get: Timeout 500ms exceeded.']

Restoring the 3000 the replaced test used clears it — verified below. The refusal path throws immediately rather than waiting, so this costs no wall time on the async test, and only the one 3s wait on the frame test.

Separately, on retiredSlots: the per-holder animation wait is removed in favour of the gate's pageSettled, but pageSettled is polled once in _render_scheme before the context is built, and retiredSlots runs about fifteen probe round trips later inside _read_scheme — it is a precondition, not a reading taken at the same moment. Is a fold that starts after that poll (a CSS animation is created at style recalc, after the rAF callback the poll runs in) reachable here, or does logApplied + presented foreclose it? The other four probes that dropped async were genuinely synchronous already; this is the one place a wait was removed rather than relocated.

Evidence

Run at head 826a629, default options (addopts = "-n 2 --dist loadgroup", 4 cores):

run command result
1 uv run pytest tests/test_render_gate.py -q 2 failed, 64 passed — test_an_async_reading_probe_is_refused_instead_of_awaited, test_a_rendering_turn_is_polled_from_the_driver
2 uv run pytest tests/test_render_gate.py -q 1 failed, 65 passed — test_an_async_reading_probe_is_refused_instead_of_awaited
3 same file at base 38bef20 (worktree) 65 passed
4 head + the two suggestions below 66 passed

Not load-specific: a two-test selection (-k "async_reading or rendering_turn") reproduced the same failure in 4.5s.

Mechanism, by symbol rather than line since the merged tree is ahead of the branch — in render_gate/scheme.py, _render_scheme sets both page._leaf_probe_timeout_ms = served_timeout_ms and served_here(path) -> served(page, url, path, timeout_ms=served_timeout_ms), and served ends return page.request.get(urljoin(url, path), timeout=timeout_ms). The try: block around the four served_here calls is what raises, and its except PlaywrightTimeout is what emits the server stopped answering.

The other tests changed here are green: the six wait_for_revision call sites in test_render_projection.py that dropped BOTH_STAMPS, the unroute_all change in test_render_outbox.py, and the tab-mark poll in test_render_startup.py all pass (10 selected, 27s).

Comment thread tests/test_render_gate.py Resolved
Comment thread tests/test_render_gate.py Resolved
Comment thread tests/test_render_gate.py Resolved
@max-sixty

Copy link
Copy Markdown
Owner Author

Addressed the reproduced blocker in 29040a39. uv run pytest tests/test_render_gate.py -q now passes all 66 cases under the repository's default -n 2; uv run pre-commit run --all-files also passes.

On retiredSlots: the gate's initial state reconciliation completes before presentPage, and runtime motion() returns no animation before presentation (with projection mode providing the other suppression condition). The fold therefore installs its terminal DOM synchronously on this path. The intervening probes only read the page; the earlier driver-bounded pageSettled poll covers independently authored finite motion before those readings begin. I corrected the source comment to state those actual invariants instead of implying that the removed per-holder wait completed a replay animation.

This was written by Codex on behalf of max-sixty

@leaf-agent

Copy link
Copy Markdown
Collaborator

Blocker cleared — reverified at 29040a39. uv run pytest tests/test_render_gate.py -q under the repo's default -n 2 is 66 passed (183.78s), and the two-test selection that reproduced the failure at 826a629 in 4.5s now passes in 6.79s.

The retiredSlots answer holds on the code: motion() returns null while runtime.projectingState is set or before data-lf-presented is on the body, and presentPage sets that attribute only once replay has completed. So a replayed fold on the gate's path installs its terminal DOM in the same task rather than as an animation, and nothing after presentation issues the gesture that would start a new one — the removed per-holder wait had nothing left to wait for. The rewritten source comment states that invariant rather than implying the wait completed a replay animation.

No remaining findings from my side; the approval is on the PR.

@max-sixty
max-sixty merged commit b8b7025 into main Aug 29, 2026
16 checks passed
@max-sixty
max-sixty deleted the codex/fix-timeout-root-causes branch August 29, 2026 04:48
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