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:
Alex Alecu
2026-02-20 17:38:35 +02:00
parent d4231c20e3
commit 7f94b83893
+6 -3
View File
@@ -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)