mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-13 22:32:04 +00:00
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.
20 lines
765 B
TypeScript
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;
|
|
}
|