From deea92581b153a2db00f9ae623ded9f3dbcec47d Mon Sep 17 00:00:00 2001 From: catlog22 Date: Sun, 1 Mar 2026 23:34:31 +0800 Subject: [PATCH] fix(cli): resolve process hang after CLI execution Root cause: HTTP Keep-Alive connections kept event loop alive, preventing process.exit() from executing even after CLI_EXECUTION_COMPLETED event was sent. Fix: Add `agent: false` and `Connection: close` header to HTTP requests in notifyDashboard() and broadcastStreamEvent() functions. - agent: false - Creates new Agent per request instead of global Keep-Alive Agent - Connection: close - Tells server to close connection after response Fixes issue where `ccw cli --tool gemini` would complete execution but Bash command would hang indefinitely. --- ccw/src/commands/cli.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ccw/src/commands/cli.ts b/ccw/src/commands/cli.ts index ebf0ee3c..f19e7cc6 100644 --- a/ccw/src/commands/cli.ts +++ b/ccw/src/commands/cli.ts @@ -51,9 +51,11 @@ function notifyDashboard(data: Record): void { path: '/api/hook', method: 'POST', timeout: 2000, // 2 second timeout to prevent hanging + agent: false, // Disable Keep-Alive to allow process exit headers: { 'Content-Type': 'application/json', - 'Content-Length': Buffer.byteLength(payload) + 'Content-Length': Buffer.byteLength(payload), + 'Connection': 'close' // Ensure connection closes after response } }); @@ -93,9 +95,11 @@ function broadcastStreamEvent(eventType: string, payload: Record