Skip to content

Commit 9ebed74

Browse files
fix(cli): retry health check after spawn failure (#3067)
PR #3150 β€” approved by aegis-gh-agent[bot] (Argus) CLI health check retry for EADDRINUSE race condition.
1 parent 7940f51 commit 9ebed74

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

β€Žsrc/commands/run.tsβ€Ž

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,20 @@ export async function handleRun(args: string[], io: CliIO): Promise<number> {
208208
writeLine(io.stdout, ' ⏳ Waiting for server...');
209209
const started = await waitForServer(baseUrl, authToken, 15_000);
210210
if (!started) {
211-
writeLine(io.stderr, ' ❌ Server failed to start within 15 seconds.');
212-
writeLine(io.stderr, ' Try starting manually: ag');
213-
return 1;
211+
// Issue #3067: Race condition β€” an existing Aegis server may be on the port
212+
// but was in a crash loop when we first checked. Retry health check once
213+
// more before giving up β€” the existing server may have recovered.
214+
writeLine(io.stdout, ' ⏳ Retrying health check (existing server may have recovered)...');
215+
if (await isServerHealthy(baseUrl, authToken)) {
216+
writeLine(io.stdout, ' βœ… Connected to existing server');
217+
} else {
218+
writeLine(io.stderr, ' ❌ Server failed to start within 15 seconds.');
219+
writeLine(io.stderr, ' Try starting manually: ag');
220+
return 1;
221+
}
222+
} else {
223+
writeLine(io.stdout, ' βœ… Server started');
214224
}
215-
writeLine(io.stdout, ' βœ… Server started');
216225
}
217226

218227
// Create session

0 commit comments

Comments
Β (0)