Files
HealthLog/src/lib/queries/retry-transient.ts
T
Marc-André Bombeck b5e799c2d6 fix(charts): degrade chart failures to one card and heal stale shells per version
The update poller and the chunk-error reload guard key on the target
version instead of disarming for the whole session, so a second deploy
re-arms the self-heal and a stale shell can no longer strand with
404ing chunks. Lazy chart imports retry once and mount inside a
per-card error boundary with a reload affordance — a failed chunk
degrades to one card instead of replacing the page. The JSON API
client attaches a fifteen-second timeout unless the caller brings its
own signal (the raw streaming path is exempt), chart queries surface
errors with a retry instead of rendering as an empty period, per-type
fetch failures reject instead of caching an empty series as fresh, and
the session and snapshot queries retry once on transient network or
server errors.
2026-06-11 21:17:27 +02:00

20 lines
765 B
TypeScript

import { ApiError } from "@/lib/api/api-fetch";
/**
* Shared TanStack `retry` predicate for the shell-critical cells
* (`useAuth`, `useDashboardSnapshot`): ONE retry on transport-level
* failures (network `TypeError`, abort/timeout `DOMException`) and on
* 5xx, never on a 4xx. A 401/403 is a real answer — retrying it only
* delays the redirect / empty-state decision — while a single transient
* blip used to flip the shell straight to the redirect spinner or flash
* the full-dashboard empty state under the former `retry: false`.
*/
export function retryOnceOnTransientError(
failureCount: number,
error: unknown,
): boolean {
if (failureCount >= 1) return false;
if (error instanceof ApiError) return error.status >= 500;
return true;
}