musistudio/claude-code-router · error · Error

Grok CLI OIDC discovery timed out after ${timeoutMs}ms.

Error message

Grok CLI OIDC discovery timed out after ${timeoutMs}ms.

What it means

The OIDC discovery fetch for Grok was aborted by its internal timeout timer, and the AbortError was converted to a descriptive timeout message. Discovery never completed, so no token endpoint is returned.

Source

Thrown at packages/core/src/agents/local-providers/grok.ts:758

  const timer = setTimeout(() => controller.abort(), timeoutMs);
  try {
    const response = await fetchWithSystemProxy(metadataUrl, {
      headers: { accept: "application/json" },
      signal: controller.signal
    });
    const text = await response.text();
    const payload = parseJsonRecord(text);
    if (!response.ok) {
      throw new Error(`Grok CLI OIDC discovery returned HTTP ${response.status}${tokenRefreshErrorMessage(payload, text)}`);
    }
    const tokenEndpoint = readString(payload?.token_endpoint) || readString(payload?.tokenEndpoint);
    if (!tokenEndpoint) {
      throw new Error("Grok CLI OIDC discovery did not return a token endpoint.");
    }
    return tokenEndpoint;
  } catch (error) {
    if (error instanceof Error && error.name === "AbortError") {
      throw new Error(`Grok CLI OIDC discovery timed out after ${timeoutMs}ms.`);
    }
    throw error;
  } finally {
    clearTimeout(timer);
  }
}

function grokCredentialFiles(): string[] {
  const explicitFile = process.env.GROK_AUTH_FILE?.trim();
  return uniqueStrings([
    explicitFile,
    path.join(grokStorageRoot(), "auth.json"),
    path.join(grokStorageRoot(), "credentials.json")
  ]);
}

function grokConfigFiles(): string[] {
  const explicitFile = process.env.GROK_CONFIG_FILE?.trim();

View on GitHub (pinned to 99f24806c6)

Solutions

  1. Retry the operation
  2. Verify the discovery host resolves and responds (curl with timing)
  3. Disable/bypass proxy or VPN for the OAuth/discovery host
  4. Increase effective network reliability or check firewall rules
Defensive patterns

Strategy: retry

Try / catch

catch (e) {
  if (e instanceof Error && e.message.includes('OIDC discovery timed out')) {
    await retryWithBackoff();
  }
}

Prevention

When it happens

Trigger: The discovery HTTP request or body read exceeds timeoutMs, the AbortController fires, and the catch block rewrites the AbortError into this error.

Common situations: Blocked or degraded network paths to the discovery host, DNS resolution hangs, VPN split-tunnel misconfiguration, or provider-side slowness during incidents.

Understand the failure class

Related errors


AI-assisted analysis of musistudio/claude-code-router@99f24806c6 (2026-08-27). Data as JSON: /api/errors/81905eb5c6e542a3. Report an issue: GitHub.