fix: Opencode hangs after exit (#3481)

Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
This commit is contained in:
Haris Gušić
2025-10-31 05:57:58 +01:00
committed by GitHub
parent 51e4c9fc4c
commit c1ada302f9
12 changed files with 86 additions and 36 deletions

View File

@@ -6,9 +6,12 @@ export async function bootstrap<T>(directory: string, cb: () => Promise<T>) {
directory,
init: InstanceBootstrap,
fn: async () => {
const result = await cb()
await Instance.dispose()
return result
try {
const result = await cb()
return result
} finally {
await Instance.dispose()
}
},
})
}

View File

@@ -56,7 +56,11 @@ export const AcpCommand = cmd({
}, stream)
log.info("setup connection")
process.stdin.resume()
await new Promise((resolve, reject) => {
process.stdin.on("end", resolve)
process.stdin.on("error", reject)
})
})
process.stdin.resume()
},
})

View File

@@ -27,6 +27,6 @@ export const ServeCommand = cmd({
})
console.log(`opencode server listening on http://${server.hostname}:${server.port}`)
await new Promise(() => {})
server.stop()
await server.stop()
},
})