diegosouzapw/OmniRoute · error · Error

Failed to fetch diversity analytics

Error message

Failed to fetch diversity analytics: ${res.status}

What it means

DiversityScoreCard's loadDiversity effect received a non-OK from GET /api/analytics/diversity and throws with the HTTP status appended. The card stays in its loading-resolved error state; server-side this happens when the diversity reporter has no window data or the analytics engine errored.

Solutions

  1. Verify the diversity analytics endpoint and its in-memory report availability
  2. Respect the cancelled flag so unmounts do not set state
  3. Check server logs for the failing diversity request
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/app/(dashboard)/dashboard/analytics/components/DiversityScoreCard.tsx:30 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/85bd09ca4a47a009. Report an issue: GitHub.

Appendix: source

Thrown at src/app/(dashboard)/dashboard/analytics/components/DiversityScoreCard.tsx:30

  score: number;
  providers: Record<string, DiversityProviderStat>;
  windowSize: number;
  ttlMs: number;
}

export default function DiversityScoreCard() {
  const t = useTranslations("analytics");
  const [data, setData] = useState<DiversityReport | null>(null);
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    let cancelled = false;

    async function loadDiversity() {
      try {
        const res = await fetch("/api/analytics/diversity");
        if (!res.ok) {
          throw new Error(`Failed to fetch diversity analytics: ${res.status}`);
        }

        const json = (await res.json()) as DiversityReport;
        if (!cancelled) {
          setData(json);
        }
      } catch (error) {
        console.error(error);
      } finally {
        if (!cancelled) {
          setLoading(false);
        }
      }
    }

    void loadDiversity();

    return () => {

View on GitHub (pinned to a179ffed5b)