abhigyanpatwari/GitNexus · error · Error

LLM request timed out after ${formatTimeoutDuration(config.r

Error message

LLM request timed out after ${formatTimeoutDuration(config.requestTimeoutMs)}. Increase --timeout or omit it to disable the request timeout.

What it means

Thrown when callLLM() set config.requestTimeoutMs (via --timeout) and the AbortSignal.timeout fired before the provider responded, and the resulting error matches isTimeoutLikeError(). The message names the elapsed duration (formatTimeoutDuration) and tells you the timeout is opt-in. By default no timeout is imposed because large local-model runs legitimately take minutes.

Source

Thrown at gitnexus/src/core/wiki/llm-client.ts:420

      {
        breakerKey: `wiki-llm-${new URL(url).host}`,
        retry: { maxAttempts: config.maxAttempts ?? 3, baseDelayMs: 2_000, capDelayMs: 30_000 },
      },
    );
  } catch (err) {
    if (err instanceof CircuitOpenError) {
      throw new Error(
        `LLM endpoint circuit open: retry in ${Math.ceil(err.retryAfterMs / 1000)}s. ${err.message}`,
      );
    }
    if (err instanceof ResilientFetchExhaustedError) {
      const errorText = await err.response.text().catch(() => 'unknown error');
      throw new Error(
        `LLM API error (${err.response.status} after retries): ${errorText.slice(0, 500)}`,
      );
    }
    if (config.requestTimeoutMs !== undefined && isTimeoutLikeError(err)) {
      throw new Error(
        `LLM request timed out after ${formatTimeoutDuration(config.requestTimeoutMs)}. ` +
          'Increase --timeout or omit it to disable the request timeout.',
      );
    }
    throw err;
  }

  if (!response.ok) {
    const errorText = await response.text().catch(() => 'unknown error');

    // Azure content filter — surface a clear message instead of a generic API error.
    if (
      azure &&
      response.status === 400 &&
      (errorText.includes('content_filter') || errorText.includes('ResponsibleAIPolicyViolation'))
    ) {
      throw new Error(
        `Azure content filter blocked this request. The prompt triggered content policy. Details: ${errorText.slice(0, 300)}`,

View on GitHub (pinned to d540b00184)

Solutions

  1. Increase --timeout (e.g. --timeout 300) to match the model's realistic latency.
  2. Omit --timeout entirely to disable the ceiling (the default path).
  3. Reduce prompt size or split the work into smaller calls.
  4. Use a faster/non-reasoning model for the bulk pass.
  5. For local servers, raise the server's own inference budget / batch size.

Example fix

# before
gitnexus wiki --llm-base-url http://localhost:11434/v1 --timeout 60
# times out on long generations

# after
gitnexus wiki --llm-base-url http://localhost:11434/v1 --timeout 600
gitnexus wiki --llm-base-url http://localhost:11434/v1   # omit to disable
Defensive patterns

Strategy: validation

Validate before calling

// Don't set requestTimeoutMs unless you know the latency profile.
// If you do, size it to p99 generation time:
const estimated = expectedOutputTokens * msPerToken * 1.5;
config.requestTimeoutMs = Math.max(60_000, estimated);

Type guard

function isLLMTimeoutError(e) {
  return e instanceof Error && /LLM request timed out after/.test(e.message);
}

Try / catch

try { return await callLLM(prompt, config); }
catch (e) {
  if (isLLMTimeoutError(e)) {
    config = { ...config, requestTimeoutMs: (config.requestTimeoutMs ?? 60_000) * 2 };
    return await callLLM(prompt, config);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling callLLM() with config.requestTimeoutMs=60000 against a slow endpoint (large prompt, reasoning model, or busy local server) where the response takes longer than 60s; the AbortSignal aborts the fetch and the rejection is recognized as a timeout.

Common situations: Setting --timeout 60 for wiki generation against a large-context model; running a local LLM (Ollama/LM Studio) that generates slowly; rate-limited shared endpoints that queue requests; reasoning models (o1/o3) that think for tens of seconds.

Understand the failure class

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12). Data as JSON: /api/errors/1299c90a0d297445. Report an issue: GitHub.