Public: anyone can read this; the crew can change it.

A cancelled run ends its whole process tree: a test starts a run whose child spawns a grandchild, cancels it, and finds neither alive #14284

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

When a run is cancelled, its log line now lists every pid the stop reached, not just how many. A cancelled check logs a line like cancel ended 3 processes: 4101 4102 4107. With no live processes it stays cancel ended 0 processes.

Notes

shipped production is serving it deploy 4adf612

opened this

When a run is cancelled, its log line now lists every pid the stop reached, not just how many. A cancelled check logs a line like cancel ended 3 processes: 4101 4102 4107. With no live processes it stays cancel ended 0 processes.

Most of this issue was already true on main. test/run-cancel-tree.test.ts (from #10829, #10930 and #11249) cancels a check whose command forks a child, which forks a long sleep. It asserts all three are gone within 2 s and the run ends cancelled. The stop already sends SIGTERM to the process group, then SIGKILL once CANCEL_GRACE_MS runs out, and runs that end normally never go through that path. The one thing missing was the run recording which pids it killed.

  • src/runs/ended.ts: endedLine now takes the pids from liveTree instead of a count. It names only positive whole numbers and keeps the cancel ended N process(es) prefix, so anything that matches on the count still works.
  • Callers: src/apps/process.ts (checks and deploys) and src/crew/claude.ts (agent runs) pass the pids.
  • Tests:
    • test/run-cancel-tree.test.ts and test/crew-cancel-group.test.ts now also assert that the command's, the child's and the grandchild's pids are each named on the cancel line.
    • test/run-cancel-ended.test.ts covers the new line format: one pid, several, none, and values that aren't pids.

I didn't add a separate ended: column or field to the run row. Its state is already cancelled and its log carries the pids, and a schema change didn't seem worth it for this.

bun scripts/gate.ts --fix and bun x tsc --noEmit pass. All 12 tests in the three files above plus test/run-cancel.test.ts pass. To try it, cancel a running check on the preview and open its log.

🤖 Generated with Claude Code

Closes #14275

commented

When a run is cancelled, its log line now lists every pid the stop reached, not just how many. A cancelled check logs a line like cancel ended 3 processes: 4101 4102 4107. With no live processes it stays cancel ended 0 processes.

Most of this issue was already true on main. test/run-cancel-tree.test.ts (from #10829, #10930 and #11249) cancels a check whose command forks a child, which forks a long sleep. It asserts all three are gone within 2 s and the run ends cancelled. The stop already sends SIGTERM to the process group, then SIGKILL once CANCEL_GRACE_MS runs out, and runs that end normally never go through that path. The one thing missing was the run recording which pids it killed.

  • src/runs/ended.ts: endedLine now takes the pids from liveTree instead of a count. It names only positive whole numbers and keeps the cancel ended N process(es) prefix, so anything that matches on the count still works.
  • Callers: src/apps/process.ts (checks and deploys) and src/crew/claude.ts (agent runs) pass the pids.
  • Tests:
    • test/run-cancel-tree.test.ts and test/crew-cancel-group.test.ts now also assert that the command's, the child's and the grandchild's pids are each named on the cancel line.
    • test/run-cancel-ended.test.ts covers the new line format: one pid, several, none, and values that aren't pids.

I didn't add a separate ended: column or field to the run row. Its state is already cancelled and its log carries the pids, and a schema change didn't seem worth it for this.

bun scripts/gate.ts --fix and bun x tsc --noEmit pass. All 12 tests in the three files above plus test/run-cancel.test.ts pass. To try it, cancel a running check on the preview and open its log.

🤖 Generated with Claude Code

Approved

Small, single-purpose, and correct: endedLine now names the pids liveTree read, both callers (apps/process.ts, crew/claude.ts) pass them, the count prefix is kept, and the tests assert the command, child and grandchild pids are each named. No UI, API or dependency change, so nothing for a phone, keyboard or no-JS reader to regress; the preview serves as before. Next two things I would do: (1) when the pid list is long, cap it (e.g. first 20 plus "and N more") so one runaway tree cannot write a huge log line; (2) add a test that the deploy path in apps/process.ts logs the named line, since only checks and crew runs are covered.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs