{"record":{"id":"d58eaecd898e8be4","repo":"diegosouzapw/OmniRoute","slug":"openrouterproviderstats-fetch-failed-using-stal","errorCode":null,"errorMessage":"[OpenRouterProviderStats] Fetch failed, using stale cache:","messagePattern":"\\[OpenRouterProviderStats\\] Fetch failed, using stale cache:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/catalog/openrouterProviderStats.ts","lineNumber":268,"sourceCode":"  fromCache: boolean;\n}> {\n  const ttl = getTTL();\n  const cache = readCache();\n  const now = Date.now();\n\n  if (cache && cache.fetchedAt) {\n    const age = now - new Date(cache.fetchedAt).getTime();\n    if (age < ttl) {\n      return { data: cache.data, stale: false, cachedAt: cache.fetchedAt, fromCache: true };\n    }\n  }\n\n  try {\n    const data = await fetchFromAPI();\n    writeCache(data);\n    return { data, stale: false, cachedAt: null, fromCache: false };\n  } catch (err) {\n    console.warn(\"[OpenRouterProviderStats] Fetch failed, using stale cache:\", err);\n    if (cache) {\n      return { data: cache.data, stale: true, cachedAt: cache.fetchedAt, fromCache: true };\n    }\n    return { data: [], stale: true, cachedAt: null, fromCache: false };\n  }\n}\n\n/** Force-refresh, ignoring TTL. Used by admin endpoints and manual refresh actions. */\nexport async function refreshOpenRouterProviderStats(): Promise<{\n  data: ProviderPopularityEntry[];\n  ok: boolean;\n  error?: string;\n}> {\n  try {\n    const data = await fetchFromAPI();\n    writeCache(data);\n    return { data, ok: true };\n  } catch (err) {","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/catalog/openrouterProviderStats.ts#L250-L286","documentation":"Error \"[OpenRouterProviderStats] Fetch failed, using stale cache:\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/catalog/openrouterProviderStats.ts:268 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}