Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

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

Simon Knott142582cb9633
diff --git a/packages/playwright-core/src/tools/dashboard/dashboardApp.ts b/packages/playwright-core/src/tools/dashboard/dashboardApp.ts
index cf338ec2af..fb35e81746 100644
--- a/packages/playwright-core/src/tools/dashboard/dashboardApp.ts
+++ b/packages/playwright-core/src/tools/dashboard/dashboardApp.ts
@@ -107,7 +107,11 @@ async function startDashboardServer(provider: SessionProvider, options: Dashboar
return await Promise.race([...connections].map(c => c.emitAnnotate({ signal: cancellation })));
};
- const close = () => httpServer.stop();
+ const close = async () => {
+ for (const c of connections)
+ c.close?.();
+ await httpServer.stop();
+ };
return { url: httpServer.urlPrefix('human-readable'), reveal, triggerAnnotate, close };
}
@@ -355,8 +359,8 @@ async function startApp(server: net.Server, options: DashboardOptions) {
socket.end(e);
}
} else if (parsed.kill) {
- socket.end();
- gracefullyProcessExitDoNotHang(0);
+ await dashboard.close().catch(() => {});
+ gracefullyProcessExitDoNotHang(0, () => new Promise(r => socket.end(r)));
} else {
try {
await page?.bringToFront();