diegosouzapw/OmniRoute · error

[OpenRouterProviderStats] Initial sync failed

Error message

[OpenRouterProviderStats] Initial sync failed: ${result.error}

What it means

The initial OpenRouter provider-stats synchronization completed but returned a non-ok result, meaning the fetch/refresh of provider statistics from OpenRouter failed (e.g. network error, non-2xx upstream response, or parse failure). This is a soft failure: the periodic sync timer is still started, so cached/stale stats remain in use until a later sync succeeds.

Solutions

  1. Check OpenRouter API availability and network egress from the server
  2. Inspect result.error to identify whether it is an HTTP status, timeout, or parse failure
  3. Wait for the next periodic sync tick to retry automatically
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at src/lib/catalog/openrouterProviderStats.ts:313 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/5bc51ff4ff8b7d59. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/catalog/openrouterProviderStats.ts:313

function getEffectiveOpenRouterProviderStatsEnabled(): boolean {
  return process.env.OPENROUTER_PROVIDER_STATS_ENABLED !== "false";
}

function startPeriodicSync(intervalMs?: number): void {
  if (syncTimer) return; // Already running

  const interval = intervalMs ?? getTTL();
  console.log(`[OpenRouterProviderStats] Starting periodic sync every ${interval / 1000}s`);

  refreshOpenRouterProviderStats()
    .then((result) => {
      if (result.ok) {
        console.log(
          `[OpenRouterProviderStats] Initial sync complete: ${result.data.length} providers`
        );
      } else {
        console.warn(`[OpenRouterProviderStats] Initial sync failed: ${result.error}`);
      }
    })
    .catch((err) => {
      console.warn(
        "[OpenRouterProviderStats] Initial sync error:",
        err instanceof Error ? err.message : err
      );
    });

  syncTimer = setInterval(() => {
    refreshOpenRouterProviderStats().catch((err) => {
      console.warn(
        "[OpenRouterProviderStats] Periodic sync error:",
        err instanceof Error ? err.message : err
      );
    });
  }, interval);
  syncTimer.unref();

View on GitHub (pinned to a179ffed5b)