Skip to content

fix(mcp): do not close the browser twice when the client disconnects - #43174

Merged
Pavel Feldman (pavelfeldman) merged 1 commit into
microsoft:mainfrom
pavelfeldman:fix-43098
Oct 6, 2026
Merged

Pavel Feldman (pavelfeldman) merged 1 commit into
microsoft:mainfrom
pavelfeldman:fix-43098

Conversation

@pavelfeldman

Copy link
Copy Markdown
Member

Summary

  • On stdin end, the MCP server closed its transport, which closed the browser, and the exit watchdog closed the browser at the same time. The second close force-killed the browser. Remove the 'end' handler, so the watchdog is the only shutdown path.
  • The 'end' handler also killed a pending browser_annotate client. That client now notices the exit of its parent by itself: it reads stdin, so the 'close' event fires.

Fixes #43098

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

On stdin end, the MCP server closed its transport, which closed the
browser, and the exit watchdog closed the browser at the same time.
The second close force-killed the browser. Remove the 'end' handler,
so the watchdog is the only shutdown path.

The 'end' handler also killed a pending browser_annotate client. That
client now notices the exit of its parent by itself: it reads stdin,
so the 'close' event fires.

Fixes: microsoft#43098
@pavelfeldman
Pavel Feldman (pavelfeldman) merged commit d6158cd into microsoft:main Oct 6, 2026
16 of 17 checks passed
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Test results for "MCP"

1 failed
❌ [firefox] › mcp/idle-timeout.spec.ts:19 › closes the browser after the idle timeout and relaunches it on the next call @mcp-windows-latest-firefox

9047 passed, 1495 skipped


Merge workflow run.

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Hi, I'm the Playwright bot and I took a first look at the latest CI run.

🟢 The remaining failure is a confirmed pre-existing flake

The PR is clear. The exact Windows Firefox test has failed on several unrelated PRs, before this change.

Details

Overall assessment

This PR changes shutdown after stdin disconnect and parent-process exit. The failing test keeps the MCP client connected and instead waits for the existing 500 ms browser idle timer, so those changed shutdown paths are not active. Its relaunch raced a browser close and returned Target page, context or browser has been closed.

Pre-existing flake / infra

Triaged by the Playwright bot - agent run

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.

[MCP]: On stdin EOF the stdio server force-kills its own browser 1 ms after starting the graceful close (Windows)

2 participants