Skip to content

Commit deea925

Browse files
author
catlog22
committed
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.
1 parent 4d17bb0 commit deea925

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

ccw/src/commands/cli.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ function notifyDashboard(data: Record<string, unknown>): void {
5151
path: '/api/hook',
5252
method: 'POST',
5353
timeout: 2000, // 2 second timeout to prevent hanging
54+
agent: false, // Disable Keep-Alive to allow process exit
5455
headers: {
5556
'Content-Type': 'application/json',
56-
'Content-Length': Buffer.byteLength(payload)
57+
'Content-Length': Buffer.byteLength(payload),
58+
'Connection': 'close' // Ensure connection closes after response
5759
}
5860
});
5961

@@ -93,9 +95,11 @@ function broadcastStreamEvent(eventType: string, payload: Record<string, unknown
9395
path: '/api/hook',
9496
method: 'POST',
9597
timeout: 1000, // Short timeout for streaming
98+
agent: false, // Disable Keep-Alive to allow process exit
9699
headers: {
97100
'Content-Type': 'application/json',
98-
'Content-Length': Buffer.byteLength(data)
101+
'Content-Length': Buffer.byteLength(data),
102+
'Connection': 'close' // Ensure connection closes after response
99103
}
100104
});
101105

0 commit comments

Comments
 (0)