Skip to content

Commit 063fec1

Browse files
fix(cli): add timeout to ag run session creation fetch (#3247)
Closes #3247 - Add AbortSignal.timeout(120_000) to POST /v1/sessions fetch - Add AbortError handling with actionable error message - Prevents silent hang when server is slow (BYO-LLM proxy setups) Root cause: no client timeout on session creation fetch. Broski (first external tester) hit this on v0.6.6. Fix needs v0.6.7 release.
1 parent b7cbb50 commit 063fec1

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/commands/run.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ export async function handleRun(args: string[], io: CliIO): Promise<number> {
232232
try {
233233
const res = await fetch(`${baseUrl}/v1/sessions`, {
234234
method: 'POST',
235+
signal: AbortSignal.timeout(120_000), // Issue #3247: prevent indefinite hang
235236
headers,
236237
body: JSON.stringify({
237238
workDir: cwd,
@@ -251,10 +252,14 @@ export async function handleRun(args: string[], io: CliIO): Promise<number> {
251252
writeLine(io.stdout, ` ✅ Session: ${session.displayName} (${sessionId.slice(0, 8)})`);
252253
} catch (e) {
253254
const cause = (e as { cause?: { code?: string } }).cause;
254-
if (cause?.code === 'ECONNREFUSED') {
255+
const errMessage = getErrorMessage(e);
256+
if (e instanceof DOMException && e.name === 'AbortError') {
257+
writeLine(io.stderr, ` ❌ Session creation timed out after 120s. The server may be slow to respond with your LLM provider.`);
258+
writeLine(io.stderr, ` Try setting AEGIS_ACP_PROMPT_TIMEOUT_MS=180000 and restarting.`);
259+
} else if (cause?.code === 'ECONNREFUSED') {
255260
writeLine(io.stderr, ` ❌ Cannot connect to server at ${baseUrl}.`);
256261
} else {
257-
writeLine(io.stderr, ` ❌ ${getErrorMessage(e)}`);
262+
writeLine(io.stderr, ` ❌ ${errMessage}`);
258263
}
259264
return 1;
260265
}

0 commit comments

Comments
 (0)