Repository navigation
Open
Labels
Description
Problem
Orphaned shellper-main.js processes are accumulating again — a regression of #389 (and the earlier #294 / #341 / #324, all CLOSED). On the dev box right now there are 51 live shellper processes but Tower's authoritative registry (GET /api/terminals, which is global across all workspaces) only tracks 27. That leaves 24 orphans — running shellpers with no Tower session attached in any workspace, all reparented to PPID 1 (their original Tower instance died).
Forensics (2026-06-06)
Method — subtract Tower's global live set from the running shellper set:
- Tower
/api/terminals: 27 tracked PIDs (codev 6 + shannon 20 + writing 1 — matches/api/workspacescounts exactly). psforshellper-main.js: 51 PIDs.- Orphans = running − tracked = 24, all PPID 1.
The 24 orphans cluster into:
| Bucket | Count | Notes |
|---|---|---|
| E2E test leftovers | 14 | ~/.agent-farm/test-workspaces/codev-reconnect-* + /tmp /bin/echo fixtures; node 25 |
| Old shannon sessions | 9 | node-25 zombies + two stray /bin/bash inside live builder worktrees (bugfix-2135, bugfix-2164) |
| Old codev session | 1 | pid was a node-25 claude session |
Two distinct leak sources
af cleanupdoesn't kill the shellper — the original af cleanup doesn't kill shellper processes — orphaned processes accumulate #389 defect. Worktree + branch + Tower row removed, but the process survives (e.g. codevbugfix-985: worktree deleted, yet Tower still lists pid 31931 as a live session — a stale-but-tracked row, a sibling of this bug).- Tower restart abandons old shellpers — the node-25→node-26 migration restarted Tower; the old node-25 shellpers detached (PPID 1) instead of being reaped. This is the Shellper processes do not survive Tower restart despite detached:true #324 failure mode resurfacing. Most of the 24 orphans are node-25.
E2E reconnect tests also leak their fixture shellpers (14 of the 24) — the test harness should tear these down.
Expected
af cleanupkills the shellper process group (and children), not just the Tower row.- Tower startup reaps shellpers from a prior instance that no client will ever reattach to (or they should self-terminate when their parent Tower dies —
detached:trueshould not mean "outlive Tower forever"). - E2E reconnect tests clean up their spawned shellpers.
- Add a reconciliation/GC pass: any
shellper-main.jsnot present in/api/terminalsis an orphan and can be reaped.
Detection one-liner
# orphans = running shellpers not in Tower's global registry
comm -23 \
<(ps -eo pid,command | grep shellper-main.js | grep -v grep | awk '{print $1}' | sort) \
<(curl -s http://127.0.0.1:4100/api/terminals | python3 -c 'import sys,json;[print(t["pid"]) for t in json.load(sys.stdin)["terminals"]]' | sort)
Activity
waleedkadous commentedon Aug 2, 2026
Fleet census 2026-08-02 (multi-workspace Tower host, prompted by a sibling workspace's audit): 201 live shellper-main.js processes, 80 tracked in /api/terminals → 121 orphans.
Breakdown (one label per PID, via the running-minus-tracked method this issue documents):
~/.agent-farm/test-workspaces/codev-reconnect-*) → filed Shellper reconnect test suite leaks its fixture shellpers: test-workspaces never tear down #1337/bin/echo ready-probewrappers, cwd=/tmp → filed Tower readiness-probe shellper wrappers are never reaped after the probe exits #1336/bin/sleep 300wrappers, cwd=/tmp (probe-adjacent)spir-0042-feature-nametest fixtureclaude/zshsessions (4claude --resume, 2 in a stale builder worktree, 1 architect session for an inactive workspace) — held for human confirmation before killing, per the live-architect scarThe sibling workspace additionally observed: Tower tabs surviving builders whose worktrees are deleted (see #1296/#1083), a respawn loop minting ~12 shellpers for one dead worktree (#1296's pattern), and a
worktree-type registry row no cleanup flag can target (#1101/#1102).waleedkadous commentedon Nov 25, 2026
Fresh evidence, on a build from
mainat6cb29ec8e(3.3.8 plus today's merges):Seven builders were cleaned up with
afx cleanup -p <n>(four BUGFIX with--keep-ignored, two SPIR, one AIR). All seven left their shellper running: 7 of 7.Killed Tower terminal, and for the BUGFIX onesWorktree removed.afx statusshowedUnregistered Shellpers: 7. Each leftover was ashellper-main.jswhose launch arguments named the cleaned-up builder's worktree (.builders/<id>/.builder-start.sh), with no child process and no entry in Tower's/api/terminals.killShellperProcesses(worktree), from af cleanup doesn't kill shellper processes — orphaned processes accumulate #389). It makes no difference whether the worktree is removed (BUGFIX) or preserved (SPIR, AIR).They were confirmed one by one (shellper, zero children, not in
/api/terminals) and sent SIGTERM; all exited and the count went to 0.A cheap regression check for a fix: spawn a builder, run
afx cleanupon it, and assert that noshellper-main.jsprocess naming its worktree remains.