Skip to content

fix: cancel render routes before closing their pages - #4699

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

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

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

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

Context closure disposes fetched responses before page.is_closed() becomes true. Replace the observer-local closed-page guard with Playwright route cancellation at each render-page cleanup boundary, including exceptional version cleanup.

The regression now orders response-body reading after request-context disposal but before page closure, through both page and widget checks. Both cases fail before the fix with Browser.new_page: Response has been disposed and pass after it; departed-sample output capture remains covered.

Closes #4231
@leaf-agent
leaf-agent merged commit f18acbf into main Oct 29, 2026
5 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-4231-route-lifetime branch October 29, 2026 12:51
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