coleam00/Archon · error

OpenAI token ${operation} request timed out.

Error message

OpenAI token ${operation} request timed out.

What it means

postTokenRequest (openai-oauth.ts:178) applies a hard 30s ceiling to every call to OpenAI's token endpoint (combined with the caller's signal via AbortSignal.any). If the request itself times out (TimeoutError) it throws 'OpenAI token <exchange|refresh> request timed out.' This prevents a hung token endpoint from leaving a bridge login stuck 'pending' for the full 10-minute session TTL.

Source

Thrown at packages/core/src/credentials/openai-oauth.ts:178

  let response: Response;
  try {
    response = await fetch(OPENAI_TOKEN_URL, {
      method: 'POST',
      headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
      body,
      // The 30s ceiling applies ALWAYS — combined with the caller's session
      // signal when present. Without it, a hung token endpoint would leave a
      // bridge login reporting `pending` for the session's full 10-minute TTL.
      signal: signal
        ? AbortSignal.any([signal, AbortSignal.timeout(30_000)])
        : AbortSignal.timeout(30_000),
    });
  } catch (error) {
    if (signal?.aborted) {
      throw new Error('Login cancelled');
    }
    if (error instanceof Error && error.name === 'TimeoutError') {
      throw new Error(`OpenAI token ${operation} request timed out.`);
    }
    throw new Error(
      `OpenAI token ${operation} request failed: ${error instanceof Error ? error.message : String(error)}`
    );
  }
  if (!response.ok) {
    // Strip the error body down to the OAuth `error` code: this message flows
    // into the bridge's session.detail (and on to the browser/CLI), and OpenAI
    // error bodies can carry account identifiers. Never include the raw body.
    const text = await response.text().catch(() => '');
    let errorCode = '';
    try {
      const parsed = JSON.parse(text) as { error?: unknown };
      if (typeof parsed.error === 'string') {
        errorCode = parsed.error;
      } else if (parsed.error && typeof parsed.error === 'object') {
        const code = (parsed.error as { code?: unknown }).code;
        if (typeof code === 'string') errorCode = code;

View on GitHub (pinned to 0773b97458)

Solutions

  1. Retry the login (exchange) or wait and retry the refresh — the timeout is transient-safe by design.
  2. Check network/proxy reachability to the OpenAI token endpoint (curl/openssl to auth.openai.com).
  3. Bypass or fix a hung corporate proxy, or add the endpoint to proxy allowlists.
  4. Check OpenAI status pages for an ongoing auth incident before deeper debugging.
Defensive patterns

Strategy: retry

Validate before calling

// Pre-check token endpoint reachability/latency
const start = Date.now();
const res = await fetch('https://auth.openai.com/.well-known/openid-configuration', { signal: AbortSignal.timeout(5000) }).catch(() => null);
if (!res) throw new Error('OpenAI auth endpoint unreachable; fix network before login.');

Try / catch

try {
  await refreshToken(refreshToken);
} catch (e) {
  if (e instanceof Error && /timed out$/.test(e.message)) {
    await sleep(2000);
    return refreshToken(refreshToken); // bounded retry with backoff
  }
  throw e;
}

Prevention

When it happens

Trigger: The POST to OPENAI_TOKEN_URL does not respond within 30 seconds — network stalls, a hanging proxy, or an unresponsive auth.openai.com endpoint — during either the authorization-code exchange or refresh flow.

Common situations: Corporate proxy buffering/hanging connections; OpenAI auth outage or degraded performance; flaky mobile/VPN network during login; firewall silently dropping long-lived connections.

Understand the failure class

Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.

Related errors


AI-assisted analysis of coleam00/Archon@0773b97458 (2026-09-01). Data as JSON: /api/errors/e2221bd07a0b3cc7. Report an issue: GitHub.