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
- Retry the login (exchange) or wait and retry the refresh — the timeout is transient-safe by design.
- Check network/proxy reachability to the OpenAI token endpoint (curl/openssl to auth.openai.com).
- Bypass or fix a hung corporate proxy, or add the endpoint to proxy allowlists.
- 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
- Ensure the host has low-latency egress to auth.openai.com.
- Allowlist the OpenAI auth endpoints on corporate proxies to avoid stalls.
- Monitor OpenAI status during incident windows.
- Keep the 30s ceiling; don't remove it — it prevents stuck pending logins.
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.
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- OpenAI token ${operation} request failed: ${error instanceof
- OpenAI token ${operation} returned a non-JSON response (HTTP
- OAuth state mismatch.
- Missing authorization code.
- Subscription login failed to start.
AI-assisted analysis of coleam00/Archon@0773b97458 (2026-09-01).
Data as JSON: /api/errors/e2221bd07a0b3cc7.
Report an issue: GitHub.