Skip to content

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

fix(cli): fix killAllDaemons to match actual daemon process command line (#39549)

Yury Semikhatskyd444bbb1e950
diff --git a/packages/playwright-core/src/cli/client/program.ts b/packages/playwright-core/src/cli/client/program.ts
index 08ce1f0546..9fcbacbf6d 100644
--- a/packages/playwright-core/src/cli/client/program.ts
+++ b/packages/playwright-core/src/cli/client/program.ts
@@ -294,7 +294,7 @@ async function killAllDaemons(): Promise<void> {
const result = execSync(
`powershell -NoProfile -NonInteractive -Command `
+ `"Get-CimInstance Win32_Process `
- + `| Where-Object { $_.CommandLine -like '*-server*' -and $_.CommandLine -like '*--daemon-*' } `
+ + `| Where-Object { $_.CommandLine -like '*run-mcp-server*' -or $_.CommandLine -like '*run-cli-server*' } `
+ `| ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue; $_.ProcessId }"`,
{ encoding: 'utf-8' }
);
@@ -308,7 +308,7 @@ async function killAllDaemons(): Promise<void> {
const result = execSync('ps aux', { encoding: 'utf-8' });
const lines = result.split('\n');
for (const line of lines) {
- if ((line.includes('-server')) && line.includes('--daemon-')) {
+ if (line.includes('run-mcp-server') || line.includes('run-cli-server')) {
const parts = line.trim().split(/\s+/);
const pid = parts[1];
if (pid && /^\d+$/.test(pid)) {