Compare commits

...
Author SHA1 Message Date
ajnart 221df8ae94 fix: address coderabbit review on #6219 2026-07-06 18:12:41 +02:00
ajnart 1fe07f8d79 fix(query-cache): guard against undefined result from superjson.parse on legacy cache entries
Fixes #6219

superjson.parse returns undefined when given plain JSON (stored by older
versions before the superjson serializer was introduced). Without the null
guard, accessing .buster on undefined throws "Cannot read properties of
undefined (reading 'buster')", which is caught and logged as
"Failed to hydrate query cache" — contributing to instability on upgrade.

Also remove now-redundant optional chaining on persisted.clientState since
persisted is guaranteed non-null at that point.
2026-07-06 18:07:52 +02:00
@@ -123,9 +123,9 @@ async function QueryCacheHydration({ userId, boardId }: { userId: string; boardI
const serialized = await getQueryCacheAsync(userId, boardId);
if (!serialized) return null;
const persisted = superjson.parse<PersistedClient>(serialized);
if (persisted.buster !== queryCacheBuster) return null;
if (!persisted?.clientState?.queries?.length) return null;
const persisted = superjson.parse<PersistedClient | undefined>(serialized);
if (!persisted || persisted.buster !== queryCacheBuster) return null;
if (!persisted.clientState?.queries?.length) return null;
return <HydrationBoundary state={persisted.clientState} />;
} catch (error) {