Skip to content

fix(mcp): serialize shared browser launch in --isolated mode#40709

Merged
yury-s merged 1 commit intomicrosoft:mainfrom
yury-s:fix-mcp-1607
May 7, 2026
Merged

fix(mcp): serialize shared browser launch in --isolated mode#40709
yury-s merged 1 commit intomicrosoft:mainfrom
yury-s:fix-mcp-1607

Conversation

@yury-s
Copy link
Copy Markdown
Member

@yury-s yury-s commented May 7, 2026

Summary

  • Concurrent clients hitting --isolated raced through factory.create and each launched its own browser; only the last assignment to sharedBrowser was tracked, leaving the rest orphaned.
  • Replace the variable with a sharedBrowserPromise set synchronously so concurrent callers await the same in-flight launch; the slot clears on rejection to allow retries.

Fixes microsoft/playwright-mcp#1607

When multiple HTTP clients call tools concurrently with --isolated, the
factory's create callback awaited createBrowserWithInfo before incrementing
clientCount, so each concurrent caller saw clientCount === 0 and launched
its own browser. Only the last assignment to sharedBrowser was tracked,
leaking the rest.

Replace sharedBrowser with sharedBrowserPromise that is set synchronously,
so concurrent callers all await the same in-flight launch. On rejection,
the slot clears so subsequent calls can retry.

Fixes: microsoft/playwright-mcp#1607
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

Test results for "MCP"

8 failed
❌ [chrome] › mcp/annotate.spec.ts:57 › should capture multiple screenshots in one annotation @mcp-windows-latest-chrome
❌ [chrome] › mcp/annotate.spec.ts:110 › should abort annotation when last screenshot is removed @mcp-windows-latest-chrome
❌ [chrome] › mcp/annotate.spec.ts:251 › should start dashboard and annotate when no dashboard is running @mcp-windows-latest-chrome
❌ [chrome] › mcp/annotate.spec.ts:297 › should annotate via direct browser_annotate MCP call @mcp-windows-latest-chrome
❌ [chrome] › mcp/annotate.spec.ts:330 › should annotate when context has no fixed viewport @mcp-windows-latest-chrome
❌ [chromium] › mcp/annotate.spec.ts:251 › should start dashboard and annotate when no dashboard is running @mcp-windows-latest-chromium
❌ [chromium] › mcp/annotate.spec.ts:273 › should enter annotate mode on fresh dashboard.tsx mount with -s --annotate @mcp-windows-latest-chromium
❌ [chromium] › mcp/annotate.spec.ts:398 › should cancel browser_annotate when the MCP client disconnects @mcp-windows-latest-chromium

6515 passed, 953 skipped


Merge workflow run.

@yury-s yury-s merged commit 5c35287 into microsoft:main May 7, 2026
15 of 18 checks passed
@yury-s yury-s deleted the fix-mcp-1607 branch May 7, 2026 18:33
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.

[Bug] Running multiple parallel async browsers in --isolated mode leaves orphan browsers. This has started happening after Release v0.0.69.

2 participants