fix(tools): report closed-page navigation errors#41928
Closed
Skn0tt wants to merge 3 commits into
Closed
Conversation
When navigating to URLs that cause Chrome to close the tab (e.g. chrome://extensions/), page.goto() can reject with a TargetClosedError before the context's page-close handler renders the "No open tabs" response. This race surfaced as a ~15% flake on Windows CI. Handle this by detecting the target-closed error combined with page.isClosed() in the navigate catch block and returning gracefully, letting the response builder find zero tabs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7aae2766-c0bc-47e7-a61a-5965796158a4
Collaborator
|
How come it is ok to swallow the error? I imagine client asks to navigate, and despite the page being closed we reply "everything is ok", and the next click command or something like that fails anyway. Shouldn't we respond with "failed to navigate the page" consistently, saying that not only the navigation has failed, but the whole page is gone? Btw, I can't believe Chromium just closes the tab - there must be something else happening. |
Normalize both page-close race orderings into an explicit navigation error instead of reporting successful Playwright code execution. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7aae2766-c0bc-47e7-a61a-5965796158a4
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7aae2766-c0bc-47e7-a61a-5965796158a4
Contributor
Test results for "MCP"7792 passed, 1269 skipped Merge workflow run. |
Member
Author
|
Good catch. The prior PR was totally ill-informed, the browser fully crashes and doesn't just close pages. Reverting: #41931 |
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.
When navigation closes the page,
page.goto()and page-close handling can race and produce inconsistent MCP responses.Normalize both race orderings into an explicit navigation error, making it clear that navigation failed and the page is gone. Failed navigation no longer reports successful Playwright code execution.
Fixes the flake from #41675.