mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
fix: ensure abort fires even if shutdown throws in serve.ts
Wrap Instance.disposeAll() and server.stop() in try/finally so abort.abort() always fires, preventing the process from hanging if either call rejects.
This commit is contained in:
@@ -18,9 +18,12 @@ export const ServeCommand = cmd({
|
||||
// kilocode_change start - graceful signal shutdown
|
||||
const abort = new AbortController()
|
||||
const shutdown = async () => {
|
||||
await Instance.disposeAll()
|
||||
await server.stop(true)
|
||||
abort.abort()
|
||||
try {
|
||||
await Instance.disposeAll()
|
||||
await server.stop(true)
|
||||
} finally {
|
||||
abort.abort()
|
||||
}
|
||||
}
|
||||
process.on("SIGTERM", shutdown)
|
||||
process.on("SIGINT", shutdown)
|
||||
|
||||
Reference in New Issue
Block a user