diegosouzapw/OmniRoute · error
[OpenRouterProviderStats] Failed to write cache:
Error message
[OpenRouterProviderStats] Failed to write cache:
What it means
Error "[OpenRouterProviderStats] Failed to write cache:" thrown in diegosouzapw/OmniRoute.
Source
Thrown at src/lib/catalog/openrouterProviderStats.ts:241
}
function readCache(): CacheFile | null {
const filePath = getCacheFilePath();
try {
if (!fs.existsSync(filePath)) return null;
return JSON.parse(fs.readFileSync(filePath, "utf8")) as CacheFile;
} catch {
return null;
}
}
function writeCache(data: ProviderPopularityEntry[]): void {
const filePath = getCacheFilePath();
const cache: CacheFile = { fetchedAt: new Date().toISOString(), data };
try {
fs.writeFileSync(filePath, JSON.stringify(cache, null, 2), "utf8");
} catch (err) {
console.warn("[OpenRouterProviderStats] Failed to write cache:", err);
}
}
/** Get provider popularity/enrichment stats, honoring the on-disk TTL cache. */
export async function getOpenRouterProviderStats(): Promise<{
data: ProviderPopularityEntry[];
stale: boolean;
cachedAt: string | null;
fromCache: boolean;
}> {
const ttl = getTTL();
const cache = readCache();
const now = Date.now();
if (cache && cache.fetchedAt) {
const age = now - new Date(cache.fetchedAt).getTime();
if (age < ttl) {
return { data: cache.data, stale: false, cachedAt: cache.fetchedAt, fromCache: true };View on GitHub (pinned to a179ffed5b)
When it happens
Trigger: Thrown at src/lib/catalog/openrouterProviderStats.ts:241 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25).
Data as JSON: /api/errors/c101b48404751cca.
Report an issue: GitHub.