fix(mcp): handle page crash event in Tab constructor#40426
Open
o070256 wants to merge 2 commits intomicrosoft:mainfrom
Open
fix(mcp): handle page crash event in Tab constructor#40426o070256 wants to merge 2 commits intomicrosoft:mainfrom
o070256 wants to merge 2 commits intomicrosoft:mainfrom
Conversation
The Tab constructor listens for the 'close' event to clean up state, but not for 'crash'. A renderer crash leaves the tab as a zombie in _tabs — technically open but non-functional. Any subsequent tool call against it will either hang or fail with confusing errors. Add a 'crash' listener that calls the same _onClose() handler, ensuring consistent cleanup regardless of how the page terminates.
Member
|
Hi, could you add a regression test for this? Look at |
Verifies that a renderer crash removes the tab from the MCP server's internal list and that subsequent tool calls succeed without hanging. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
|
@microsoft-github-policy-service agree |
Member
|
Now that I see the test, I'm not sure this is the right behaviour. When the page crashes, we want the agent to get some sort of a notification about it, not just the page to disappear. Similar to what we do in |
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.
Summary
The
Tabconstructor registers listeners for various page events, includingclose, but notcrash. These are two distinct Playwright events:close— fired when a page is closed normallycrash— fired when the renderer process crashes (e.g. OOM, GPU crash, or certain unhandled conditions in complex SPAs)When a renderer crash occurs,
_onClose()is never called, leaving the tab as a zombie in the_tabsarray — technically present but non-functional. Any subsequent tool call that tries to interact with the page will either hang indefinitely or fail with confusing errors likeTarget closed, without the MCP server properly recovering.Change
Add a single
crashevent listener that calls the same_onClose()handler already used forclose:This ensures consistent cleanup regardless of how the page terminates.
Testing
Manually verified by navigating to a page that triggers a renderer crash — after the fix, the MCP backend correctly removes the tab and recovers on the next tool call.