Skip to content

fix(mcp): tear down dashboard server on cli show --kill#40968

Open
Skn0tt wants to merge 1 commit into
microsoft:mainfrom
Skn0tt:fix-mcp-dashboard-kill-cleanup
Open

fix(mcp): tear down dashboard server on cli show --kill#40968
Skn0tt wants to merge 1 commit into
microsoft:mainfrom
Skn0tt:fix-mcp-dashboard-kill-cleanup

Conversation

@Skn0tt
Copy link
Copy Markdown
Member

@Skn0tt Skn0tt commented May 22, 2026

Summary

  • cli show --kill on the dashboard never closed the dashboard's HTTP/WS server, so DashboardConnection.oncloseAttachedPage.disposepage.screencast.stop never ran. The active screencast was still up when the daemon then tried to graceful-close the bound browser, and on Windows the 30s gracefullyProcessExitDoNotHang safety timer consistently won — making cli show --kill take ~30s in MCP CI jobs (e.g. https://github.com/microsoft/playwright/actions/runs/26235830215/job/77208610752).
  • DashboardServer.close() now closes WS connections before stopping the HTTP server (matches the WSServer.close() / CDPRelay.stop() pattern in the repo).
  • The --kill branch awaits dashboard.close() before scheduling exit, and moves socket.end() into gracefullyProcessExitDoNotHang's onExit so the cli client only sees the IPC FIN at actual process exit.

Follow-up to #40967 (same root-cause investigation; that one disconnects the per-tracker upstream browser connection on dispose).

The --kill handler in dashboardApp.ts only called
gracefullyProcessExitDoNotHang and never tore down the dashboard's
HTTP/WS server. As a result DashboardConnection.onclose never fired,
AttachedPage.dispose never ran, and the active screencast pipeline to
the daemon-side browser was still up when the daemon then tried to
gracefully close it. On Windows that race let the 30s
gracefullyProcessExitDoNotHang safety timer win every time, making
cli show --kill consistently take ~30s in MCP CI jobs.

- DashboardServer.close() now closes WS connections before stopping the
  HTTP server (matches the WSServer.close() / CDPRelay.stop() pattern).
- The --kill branch awaits dashboard.close() before scheduling exit.
- socket.end() moves into gracefullyProcessExitDoNotHang's onExit so the
  cli client only sees the IPC FIN at actual process exit.
@github-actions
Copy link
Copy Markdown
Contributor

Test results for "MCP"

1 failed
❌ [msedge] › mcp/cli-core.spec.ts:37 › preserves URL with & query params @mcp-windows-latest-msedge

7180 passed, 1113 skipped


Merge workflow 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.

1 participant