Bug Fixes
Zombie Process Prevention (#1168, #1175)
Observer Claude CLI subprocesses were accumulating as zombies — processes that never exited after their session ended, causing massive resource leaks on long-running systems.
Root cause: When observer sessions ended (via idle timeout, abort, or error), the spawned Claude CLI subprocesses were not being reliably killed. The existing ensureProcessExit() in SDKAgent only covered the happy path; sessions terminated through SessionRoutes or worker-service bypassed process cleanup entirely.
Fix — dual-layer approach:
- Immediate cleanup: Added
ensureProcessExit()calls to thefinallyblocks in bothSessionRoutes.tsandworker-service.ts, ensuring every session exit path kills its subprocess - Periodic reaping: Added
reapStaleSessions()toSessionManager— a background interval that scans~/.claude-mem/observer-sessions/for stale PID files, verifies the process is still running, and kills any orphans with SIGKILL escalation
This ensures no observer subprocess survives beyond its session lifetime, even in crash scenarios.