Skip to content

fix: shutdown ACP backend on session kill to reap CC child processes (#3184)#3191

Merged
aegis-gh-agent[bot] merged 1 commit into
developfrom
fix/3184-kill-session-reap-cc-processes
May 11, 2026
Merged

fix: shutdown ACP backend on session kill to reap CC child processes (#3184)#3191
aegis-gh-agent[bot] merged 1 commit into
developfrom
fix/3184-kill-session-reap-cc-processes

Conversation

@OneStepAt4time

Copy link
Copy Markdown
Owner

Summary

Root cause: killSession() in session.ts only marks the session as killed in state — it never calls acpBackend.shutdownSession() to terminate the actual Claude Code child process. Each orphaned CC process consumes ~250MB RSS, eventually causing OOM kills that block all development.

Fix

In the DELETE /v1/sessions/:id handler (src/routes/sessions.ts), call acpBackend.shutdownSession() before sessions.killSession().

The shutdownSession call:

  1. Finds the ACP runtime for the session
  2. Calls client.shutdown() which does: close stdin → wait for graceful exit → SIGTERM → wait → SIGKILL
  3. Cleans up the runtime from the runtimes map

Best-effort with .catch(() => {}) — session may not have an ACP runtime (non-ACP mode, already crashed process).

Evidence

# Before fix: 6 killed sessions, 6 orphaned CC processes consuming ~1.3GB
PID 1080757 — session f5df9dcf (198MB RSS)
PID 1353742 — session 44eeb640 (257MB RSS)
PID 1357885 — session 4ba6aa54 (252MB RSS)

Verification

npx tsc --noEmit  ✓ zero errors
npm run build     ✓ success

Files changed

  • src/routes/sessions.ts — add acpBackend.shutdownSession() call before sessions.killSession()

Fixes #3184.

…3184)

Root cause: killSession() in session.ts only marks the session as 'killed'
in state — it never calls acpBackend.shutdownSession() to terminate the
actual Claude Code child process. Each orphaned CC process consumes ~250MB RSS,
eventually causing OOM kills that block all development.

Fix: In the DELETE /v1/sessions/:id handler, call acpBackend.shutdownSession()
before sessions.killSession(). The shutdown follows the existing SIGTERM →
wait → SIGKILL escalation in AcpChildProcess.

Best-effort with .catch(() => {}) — session may not have an ACP runtime
(e.g., non-ACP mode or already crashed process).

Refs: #3184

@aegis-gh-agent aegis-gh-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved. 9-line surgical fix for #3184.\n\nRoot cause: DELETE /v1/sessions/:id never called acpBackend.shutdownSession() — CC child process left as orphan (~250MB RSS each).\n\nFix: Calls shutdown (SIGTERM → wait → SIGKILL via shutdownRuntime) before marking killed. Best-effort .catch(() => {}) for sessions without ACP runtime. Guards on acpBackend && ctx.config.acpEnabled.\n\nshutdownSession signature verified — sessionId, tenantId, ownerKeyId match AcpBackendShutdownSessionInput. No new dependencies. CI running.

@aegis-gh-agent aegis-gh-agent Bot merged commit 1a30dd0 into develop May 11, 2026
18 checks passed
@aegis-gh-agent aegis-gh-agent Bot deleted the fix/3184-kill-session-reap-cc-processes branch May 11, 2026 08:54
aegis-gh-agent Bot pushed a commit that referenced this pull request May 11, 2026
Covers PRs #3176-#3197 merged after the initial CHANGELOG update (#3175):
- Added: budget progress bars (#3183), Telegram verbose mode (#3196),
  dashboard i18n (#3192)
- Fixed: RBAC guards (#3187), process reap (#3191), i18n aria-labels (#3195),
  security helpers (#3177)
- Docs: threat matrix (#3176), blog (#3179), RBAC docs (#3188, #3193),
  tg-verbose docs (#3197)
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.

1 participant