Skip to content

Commit 1a30dd0

Browse files
fix: shutdown ACP backend on session kill to reap CC child processes (#3184)
Call acpBackend.shutdownSession() before sessions.killSession() in DELETE /v1/sessions/:id handler. Prevents orphaned Claude Code processes (~250MB RSS each) that accumulate and cause OOM kills.\n\nFixes #3184
1 parent 8ff853d commit 1a30dd0

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/routes/sessions.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,15 @@ export function registerSessionRoutes(app: FastifyInstance, ctx: RouteContext):
291291
continue;
292292
}
293293
try {
294+
// #3184: Shutdown ACP backend (CC child process) before marking session killed.
295+
// Without this, the CC process becomes an orphan consuming ~250MB RSS.
296+
if (acpBackend && ctx.config.acpEnabled) {
297+
await acpBackend.shutdownSession({
298+
sessionId: id,
299+
tenantId: req.tenantId ?? SYSTEM_TENANT,
300+
ownerKeyId: req.authKeyId ?? 'master',
301+
}).catch(() => {}); // Best-effort: session may not have ACP runtime
302+
}
294303
await sessions.killSession(id);
295304
eventBus.emitEnded(id, 'killed');
296305
void channels.sessionEnded(makePayload(sessions, 'session.ended', id, 'killed'));

0 commit comments

Comments
 (0)