diegosouzapw/OmniRoute · error

[OpenRouterCatalog] Failed to write cache:

Error message

[OpenRouterCatalog] Failed to write cache:

What it means

Error "[OpenRouterCatalog] Failed to write cache:" thrown in diegosouzapw/OmniRoute.

Source

Thrown at src/lib/catalog/openrouterCatalog.ts:84

    if (!fs.existsSync(filePath)) return null;
    const raw = fs.readFileSync(filePath, "utf8");
    return JSON.parse(raw) as CacheFile;
  } catch {
    return null;
  }
}

/** Write catalog to disk cache. */
function writeCache(data: CatalogEntry[]): 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("[OpenRouterCatalog] Failed to write cache:", err);
  }
}

/** Fetch fresh catalog from OpenRouter API. */
async function fetchFromAPI(): Promise<CatalogEntry[]> {
  const res = await fetch(OPENROUTER_API_URL, {
    headers: {
      "User-Agent": "OmniRoute/2.0",
      Accept: "application/json",
    },
    signal: AbortSignal.timeout(15_000),
  });

  if (!res.ok) {
    throw new Error(`OpenRouter API returned ${res.status}: ${res.statusText}`);
  }

  const json = (await res.json()) as { data?: CatalogEntry[] };

View on GitHub (pinned to a179ffed5b)

When it happens

Trigger: Thrown at src/lib/catalog/openrouterCatalog.ts:84 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/50871a8d2bc4dcb3. Report an issue: GitHub.