Skip to content

kill-suite-strays.mjs

Frees the browser suite's two ports by killing whatever still holds them.

Contributor toolingkill-suite-strays.mjs

What it does

Resolves the process listening on each of the browser suite's ports and kills those processes alone. An interrupted npm run test:browser leaves its vite and wrangler children running; they keep the ports, and test/browser/run.mjs then refuses every later run with "already answering".

Killing by image name is not available here. The strays are node.exe, and so is every agent session and this script itself, so the ports are the only handle that names the strays and nothing else.

Usage

Run it from the repository root, while no suite run is active:

bash
node tools/kill-suite-strays.mjs [--dry-run]

Options

FlagValueWhat it doesDefault
--dry-runnoneReports each process it would kill and kills nothing.off; without it the processes are killed

Inputs and outputs

Takes no input beyond the flag. The ports come from test/browser/suite-ports.mjs, which derives them from this checkout's own path, so a second checkout has its own pair and is never touched.

Prints one line per port: the pid it killed, the pid it could not kill, or that nothing was listening. Exits 0 in every case, including when both ports are already free — a clean box is the expected state, not a failure.

Examples

See what is holding the ports before killing anything:

bash
node tools/kill-suite-strays.mjs --dry-run

Clear the ports after an interrupted suite run, so the next one can start:

bash
node tools/kill-suite-strays.mjs && npm run test:browser

Notes

A pid that exits between the scan and the kill reports as "could not kill". That is the race resolving itself, not a problem to chase.

This kills the suite's servers, never the development loop's. scripts/dev.mjs takes a different port pair and a different store; stop that one with node scripts/dev.mjs stop.

Source

tools/kill-suite-strays.mjs — part of Contributor tooling

See also: test/browser/suite-ports.mjs the ports, derived from this checkout's path