Skip to content

fix: cancel output observation when its page closes - #4578

Merged
leaf-agent merged 1 commit into
mainfrom
fix/issue-4231
Oct 28, 2026
Merged

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

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Closing a render-check context while the output observer reads a fetched runtime entry can leave Response has been disposed in Playwright's shared connection. The next test then fails at Browser.new_page, hiding the originating callback. The observer now treats Playwright errors after its page closes as cancellation across the whole entry callback; errors on live pages still propagate, and fetch failures still abort their browser request.

The regression holds the response-body boundary until context closure, then opens another page on the same browser. It fails before the fix with the reported Browser.new_page: Response has been disposed and passes afterward. This preserves #4205's output observation, including invalid publications from removed and navigated sample documents.

Validation: the regression, both originally reported cases, the entry-route lifetime case, fetch-failure reporting, and both departed-sample cases passed (7 distinct cases). Ruff checks, formatting, and Python compilation passed. The separate package-output check fails on unchanged main with a LayerComposition argument mismatch, tracked in #4577.

Closes #4231 — automated triage

Closing a context during the response body read leaves an event-listener error in the shared Playwright connection, which the next Browser.new_page call reports as a disposed response. Treat errors after page closure as cancellation across the entire route callback, while preserving errors from live pages and the existing fetch-failure network diagnostic.

The regression orders context closure at the body-read boundary and fails on the old code with Browser.new_page: Response has been disposed. Departed-sample output capture remains intact.

Closes #4231
@leaf-agent
leaf-agent merged commit 0978030 into main Oct 28, 2026
5 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-4231 branch October 28, 2026 09:27
leaf-agent added a commit that referenced this pull request Oct 29, 2026
Render checks now cancel their route handlers before closing the page,
so an unfinished output-observer body read cannot leave `Response has
been disposed` in Playwright's shared connection and break the next
`Browser.new_page()` call. This covers page checks, widget checks, and
exceptional version cleanup through one helper using
`page.unroute_all(behavior="ignoreErrors")`.

#4578 guarded the callback with `page.is_closed()`, but context closure
disposes fetched responses before that flag becomes true. The revised
regression holds the real request-context disposal boundary open until
the observer reads its disposed response. Both page-check and
widget-check cases fail before this fix with the exact reported
diagnostic and pass afterward. The callback-local guard is removed; live
callback failures still propagate, and output observation from removed
or navigated samples is preserved.

Validation: 9 focused browser cases and 6 render-gate model checks
passed; Ruff lint and formatting, ty, and Python compilation passed. The
browser selection includes both originally reported cases, entry-route
lifetime, fetch-failure reporting, classic authored scripts, and
departed-sample output capture. Review and CI follow-up use the queued
workflows with `await_ci: false`.

Closes #4231 — 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.

Browser page creation fails with a disposed Playwright response

1 participant