Skip to content

Commit ad3c192

Browse files
committed
tui: exit cleanly without hanging after session ends
- Force process exit after TUI thread completes to prevent lingering processes - Add 5-second timeout to worker shutdown to prevent indefinite hangs during cleanup
1 parent 5512231 commit ad3c192

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

packages/opencode/src/cli/cmd/tui/thread.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,6 @@ export const TuiThreadCommand = cmd({
184184
} finally {
185185
unguard?.()
186186
}
187+
process.exit(0)
187188
},
188189
})

packages/opencode/src/cli/cmd/tui/worker.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,12 @@ export const rpc = {
137137
async shutdown() {
138138
Log.Default.info("worker shutting down")
139139
if (eventStream.abort) eventStream.abort.abort()
140-
await Instance.disposeAll()
140+
await Promise.race([
141+
Instance.disposeAll(),
142+
new Promise((resolve) => {
143+
setTimeout(resolve, 5000)
144+
}),
145+
])
141146
if (server) server.stop(true)
142147
},
143148
}

0 commit comments

Comments
 (0)