Skip to content

fix(server): close browsers when PlaywrightServer shuts down#40294

Merged
pavelfeldman merged 1 commit intomicrosoft:mainfrom
pavelfeldman:fix-browser-leak-on-server-close
Apr 18, 2026
Merged

fix(server): close browsers when PlaywrightServer shuts down#40294
pavelfeldman merged 1 commit intomicrosoft:mainfrom
pavelfeldman:fix-browser-leak-on-server-close

Conversation

@pavelfeldman
Copy link
Copy Markdown
Member

Summary

  • In extension/reuse mode, PlaywrightServer launches browsers that intentionally outlive individual client connections (for reuse across reconnects). However, when the server itself shuts down via close(), those browsers were never cleaned up — leaking browser processes.
  • This caused consistent worker teardown timeouts (30s) for debug-controller.spec.ts on all three Edge/macOS CI bots. The orphaned Edge process kept SmartScreen background connections alive, preventing clean shutdown of worker-scoped test fixtures.
  • Fix: after closing the WebSocket server (which runs per-connection dispose callbacks), close any browsers still owned by the server's Playwright instance.

In extension/reuse mode, PlaywrightServer launches browsers that
intentionally outlive individual client connections (for reuse). But
when the server itself closes, those browsers were never cleaned up,
leaking browser processes.

This caused worker teardown timeouts on Edge/macOS CI: the orphaned
Edge process kept SmartScreen background connections alive, preventing
clean shutdown of worker-scoped test fixtures.
@github-actions
Copy link
Copy Markdown
Contributor

Test results for "MCP"

14 failed
❌ [chrome] › mcp/dashboard.spec.ts:135 › should capture annotations via show --annotate @mcp-windows-latest
❌ [chrome] › mcp/dashboard.spec.ts:156 › should start dashboard and annotate when no dashboard is running @mcp-windows-latest
❌ [chromium] › mcp/dashboard.spec.ts:135 › should capture annotations via show --annotate @mcp-windows-latest
❌ [chromium] › mcp/dashboard.spec.ts:156 › should start dashboard and annotate when no dashboard is running @mcp-windows-latest
❌ [firefox] › mcp/cli-devtools.spec.ts:141 › video-start-stop @mcp-windows-latest
❌ [firefox] › mcp/cli-devtools.spec.ts:155 › video-chapter @mcp-windows-latest
❌ [firefox] › mcp/cli-session.spec.ts:50 › close @mcp-windows-latest
❌ [firefox] › mcp/cli-session.spec.ts:85 › close-all @mcp-windows-latest
❌ [firefox] › mcp/dashboard.spec.ts:135 › should capture annotations via show --annotate @mcp-windows-latest
❌ [firefox] › mcp/dashboard.spec.ts:156 › should start dashboard and annotate when no dashboard is running @mcp-windows-latest
❌ [webkit] › mcp/dashboard.spec.ts:135 › should capture annotations via show --annotate @mcp-windows-latest
❌ [webkit] › mcp/dashboard.spec.ts:156 › should start dashboard and annotate when no dashboard is running @mcp-windows-latest
❌ [msedge] › mcp/dashboard.spec.ts:135 › should capture annotations via show --annotate @mcp-windows-latest
❌ [msedge] › mcp/dashboard.spec.ts:156 › should start dashboard and annotate when no dashboard is running @mcp-windows-latest

6407 passed, 976 skipped


Merge workflow run.

@github-actions
Copy link
Copy Markdown
Contributor

Test results for "tests 1"

1 failed
❌ [installation tests] › playwright-electron-should-work.spec.ts:21 › electron should work @package-installations-ubuntu-latest

5 flaky ⚠️ [installation tests] › playwright-electron-should-work.spec.ts:31 › electron should work with special characters in path `@package-installations-ubuntu-latest`
⚠️ [chromium-library] › library/video.spec.ts:719 › screencast › should work with video+trace `@ubuntu-22.04-chromium-tip-of-tree`
⚠️ [chromium-library] › library/video.spec.ts:476 › screencast › should capture static page in persistent context @smoke `@chromium-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1080 › cli codegen › should not throw csp directive violation errors `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-page] › page/page-emulate-media.spec.ts:144 › should keep reduced motion and color emulation after reload `@firefox-ubuntu-22.04-node20`

39242 passed, 847 skipped


Merge workflow run.

@pavelfeldman pavelfeldman merged commit 0980ce6 into microsoft:main Apr 18, 2026
35 of 38 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.

3 participants