Skip to content

fix(cli): kill-all should match cliDaemon.js entry point#40166

Open
bgilly wants to merge 1 commit intomicrosoft:mainfrom
bgilly:fix-kill-all-cliDaemon
Open

fix(cli): kill-all should match cliDaemon.js entry point#40166
bgilly wants to merge 1 commit intomicrosoft:mainfrom
bgilly:fix-kill-all-cliDaemon

Conversation

@bgilly
Copy link
Copy Markdown

@bgilly bgilly commented Apr 11, 2026

Fixes #40165

Problem

playwright-cli kill-all does not kill any main daemon processes because killAllDaemons in tools/cli-client/program.ts greps for substrings that don't match current daemon command lines. Full investigation and reproduction in the linked issue.

Fix

Replace the three dead patterns (run-mcp-server, run-cli-server, cli-daemon) with cliDaemon.js — the actual entry-point filename for daemons spawned from src/entry/cliDaemon.ts. Keeps the working dashboardApp.js pattern from #40004.

Verification

Empirically verified on macOS 26.2 / Darwin 25.2.0 arm64, @playwright/cli@0.1.6 / playwright-core 1.60.0-alpha-1775584683000:

  1. Baseline: pgrep -f cliDaemon.js → 0 matches.
  2. Spawn fresh daemon: playwright-cli open → "Browser default opened with pid 19665".
  3. Confirm alive: pgrep -lf cliDaemon.js → PID 19665.
  4. playwright-cli kill-all (with patched bundle): Killed daemon process 19665. Killed 1 daemon processes.
  5. Verify dead: pgrep -f cliDaemon.js → 0 matches. playwright-cli list(no browsers).

Before the patch, step 4 produced No daemon processes found and the daemon survived.

Notes

  • No existing test covers killAllDaemons. Happy to add a spawn-and-kill test in a follow-up if the minimal fix is acceptable.
  • npm run lint passes on the modified file locally.
  • Secondary issue observed during investigation (out of scope): once a daemon is SIGKILL'd by kill-all, its child browser process becomes an orphan because SIGKILL prevents the daemon from running a cleanup handler. Worth a follow-up to SIGTERM first with a brief grace period. Separate concern from the pattern mismatch fixed here.

killAllDaemons grepped process command lines for 'cli-daemon',
'run-mcp-server', and 'run-cli-server'. None of these match real
daemons today:

- 'cli-daemon' was intended to match the cliDaemon.js entry point
  added in microsoft#39632 but the case is wrong (camelCase vs hyphenated).
- 'run-mcp-server' and 'run-cli-server' were argv tokens from the
  pre-microsoft#39632 daemon launch mechanism. They no longer appear in any
  process command line.

Only the dashboardApp.js pattern added in microsoft#40004 matched anything.

Replace the three dead patterns with 'cliDaemon.js'. Verified
empirically on macOS: kill-all now kills real orphan daemons where
it previously reported "No daemon processes found."

Fixes microsoft#40165
@bgilly bgilly marked this pull request as ready for review April 11, 2026 05:34
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]: playwright-cli kill-all does not kill daemons due to pattern mismatch in killAllDaemons

1 participant