fix(coding-agent): fail fast when RPC startup exits early

This commit is contained in:
can1357
2026-02-20 11:01:37 +01:00
parent 6bf59bf89c
commit c8230be4a7
3 changed files with 27 additions and 16 deletions
@@ -134,15 +134,11 @@ export class RpcClient {
// Wait a moment for process to initialize
await Bun.sleep(100);
try {
const exitCode = await Promise.race([this.#process.exited, Bun.sleep(500).then(() => null)]);
if (exitCode !== null) {
throw new Error(
`Agent process exited immediately with code ${exitCode}. Stderr: ${this.#process.peekStderr()}`,
);
}
} catch {
// Process still running, which is what we want
const exitCode = await Promise.race([this.#process.exited, Bun.sleep(500).then(() => null)]);
if (exitCode !== null) {
throw new Error(
`Agent process exited immediately with code ${exitCode}. Stderr: ${this.#process.peekStderr()}`,
);
}
}