fix(mcp): handle page crash event in Tab constructor#40426
fix(mcp): handle page crash event in Tab constructor#40426pavelfeldman merged 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.
|
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>
|
@microsoft-github-policy-service agree |
|
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 |
Test results for "MCP"3 failed 6808 passed, 937 skipped Merge workflow run. |
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.