{"record":{"id":"c048e14030e25659","repo":"musistudio/claude-code-router","slug":"kimi-cli-oauth-token-refresh-timed-out-after-kim","errorCode":null,"errorMessage":"Kimi CLI OAuth token refresh timed out after ${kimiOauthRefreshTimeoutMs}ms.","messagePattern":"Kimi CLI OAuth token refresh timed out after (.+?)ms\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/agents/local-providers/kimi.ts","lineNumber":447,"sourceCode":"    const refreshToken = readString(payload?.refresh_token) || readString(payload?.refreshToken);\n    const expiresIn = numberValue(payload?.expires_in) ?? numberValue(payload?.expiresIn);\n    if (!accessToken || !refreshToken || !expiresIn) {\n      throw new Error(\"Kimi CLI OAuth token refresh returned an incomplete token response.\");\n    }\n    const refreshed: KimiTokenSet = {\n      ...auth,\n      accessToken,\n      expiresAt: Math.floor(Date.now() / 1000) + expiresIn,\n      expiresIn,\n      refreshToken,\n      scope: readString(payload?.scope) || auth.scope || \"\",\n      tokenType: readString(payload?.token_type) || readString(payload?.tokenType) || \"Bearer\"\n    };\n    persistKimiAuth(refreshed);\n    return refreshed;\n  } catch (error) {\n    if (error instanceof Error && error.name === \"AbortError\") {\n      throw new Error(`Kimi CLI OAuth token refresh timed out after ${kimiOauthRefreshTimeoutMs}ms.`);\n    }\n    throw error;\n  } finally {\n    clearTimeout(timer);\n  }\n}\n\nfunction persistKimiAuth(auth: KimiTokenSet): void {\n  if (!auth.accessToken || !auth.refreshToken) {\n    return;\n  }\n  const payload = {\n    access_token: auth.accessToken,\n    refresh_token: auth.refreshToken,\n    expires_at: auth.expiresAt ?? 0,\n    scope: auth.scope ?? \"\",\n    token_type: auth.tokenType ?? \"Bearer\",\n    expires_in: auth.expiresIn ?? 0","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/musistudio/claude-code-router/blob/99f24806c6a2c660b16e53e95211c517448a6c90/packages/core/src/agents/local-providers/kimi.ts#L429-L465","documentation":"The Kimi OAuth refresh HTTP request exceeded kimiOauthRefreshTimeoutMs and was aborted via AbortController. The request may be slow or the network hanging.","triggerScenarios":"fetch in refreshKimiAuth does not settle before the setTimeout fires, the abort triggers AbortError, which is rethrown as this timeout error.","commonSituations":"Slow/blocked network, firewall dropping packets silently, DNS hang, or an overloaded auth endpoint.","solutions":["Verify network connectivity to the Kimi auth domain.","Retry — transient slowness often resolves.","Check if a proxy env var (HTTPS_PROXY) points at a dead proxy.","Raise kimiOauthRefreshTimeoutMs if on a legitimately slow link."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await refreshKimiAuth(auth); } catch (e) { if (/timed out/.test(String((e as Error).message))) await sleep(backoff()); else throw e; }","preventionTips":["Set sane proxy env vars.","Retry with exponential backoff on timeouts."],"tags":["kimi","oauth","timeout","abort"],"backgroundTag":"http-request-timeout","analyzedSha":"99f24806c6a2c660b16e53e95211c517448a6c90","analyzedAt":"2026-08-27T04:11:01.184Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}