Repository navigation
fix: cancel render routes before closing their pages - #4699
Merged
Merged
Conversation
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
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.
Render checks now cancel their route handlers before closing the page, so an unfinished output-observer body read cannot leave
Response has been disposedin Playwright's shared connection and break the nextBrowser.new_page()call. This covers page checks, widget checks, and exceptional version cleanup through one helper usingpage.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