Skip to content

fix(mcp): surface unhandled rejections instead of crashing the server#40452

Merged
pavelfeldman merged 2 commits intomicrosoft:mainfrom
pavelfeldman:fix-mcp-1572
Apr 28, 2026
Merged

fix(mcp): surface unhandled rejections instead of crashing the server#40452
pavelfeldman merged 2 commits intomicrosoft:mainfrom
pavelfeldman:fix-mcp-1572

Conversation

@pavelfeldman
Copy link
Copy Markdown
Member

Summary

  • Capture process-level unhandledRejection events in the MCP Context and surface them on the next tool response, so a user-installed callback (e.g. a page.route handler) that throws asynchronously no longer tears down the MCP transport.

Fixes microsoft/playwright-mcp#1572

Capture process-level unhandled rejections in Context and append them to
the next tool response, so a user-installed callback (e.g. a page.route
handler) that throws asynchronously no longer tears down the MCP transport.

Fixes: microsoft/playwright-mcp#1572
@github-actions

This comment has been minimized.

Awaiting __fn__ alone deadlocks when a user-installed callback (e.g. a
page.route handler) throws asynchronously: page.evaluate keeps waiting
for the orphaned route, the IIFE never settles, and the tool hangs until
the test/action timeout. Subscribe to Context's unhandledRejection feed
inside runCode and reject __end__ to break out, while the Context-level
handler still records the rejection for the response.
@github-actions
Copy link
Copy Markdown
Contributor

Test results for "MCP"

3 failed
❌ [firefox] › mcp/cli-devtools.spec.ts:204 › video-start-stop @mcp-windows-latest
❌ [firefox] › mcp/cli-devtools.spec.ts:218 › video-chapter @mcp-windows-latest
❌ [firefox] › mcp/cli-session.spec.ts:115 › session stops when browser exits @mcp-windows-latest

6805 passed, 927 skipped


Merge workflow run.

@pavelfeldman pavelfeldman merged commit 6c31c20 into microsoft:main Apr 28, 2026
10 of 11 checks passed
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_run_code: exception in page.route callback closes MCP transport

2 participants