fix: use SuperJSON for cache persistence and add null guards to all widgets

SuperJSON preserves Date/Map/Set types through the Redis cache round-trip,
fixing RangeError crashes from date formatting. Added defensive null/undefined
guards across all widget components to handle useQuery loading states and
potential cache shape mismatches.
This commit is contained in:
Thomas Camlong committed 2026-07-04 10:19:16 +02:00
1 parent e20053b2c1
commit cf075040e8
31 files changed
+124 -117

No files matched your search

@@ -7,6 +7,7 @@ import "~/styles/gridstack.scss";
import { dehydrate, HydrationBoundary } from "@tanstack/react-query";
import type { PersistedClient } from "@tanstack/react-query-persist-client";
import SuperJSON from "superjson";
import { getQueryClient } from "@homarr/api/server";
import { IntegrationProvider } from "@homarr/auth/client";
import { auth } from "@homarr/auth/next";
@@ -121,7 +122,7 @@ async function QueryCacheHydration({ userId, boardId }: { userId: string; boardI
const serialized = await getQueryCacheAsync(userId, boardId);
if (!serialized) return null;
const persisted = JSON.parse(serialized) as PersistedClient;
const persisted = SuperJSON.parse<PersistedClient>(serialized);
if (!persisted?.clientState?.queries?.length) return null;
return <HydrationBoundary state={persisted.clientState} />;