fix(offline): include provided in RTKQ rehydration payload
RTK Query 2.12's invalidation slice reads `provided.tags` during cache
rehydration (`Object.entries(provided.tags ?? {})`). Our persisted
snapshot only carried `{ queries, mutations }`, so `provided` was
undefined and `.tags` threw on every startup with a cached snapshot —
crashing the app inside the rehydrate reducer / immer produce.
Snapshot now carries the real `provided` (so invalidation tags
rehydrate), and `load()` defaults it to `{ tags: {}, keys: {} }` so
snapshots persisted before this field existed recover without a manual
localStorage clear.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,11 @@ export const REHYDRATE_API = 'api/rehydrate';
|
||||
export interface RehydrateApiPayload {
|
||||
queries: Record<string, unknown>;
|
||||
mutations: Record<string, unknown>;
|
||||
// RTKQ's invalidation slice reads `provided.tags`/`provided.keys` during
|
||||
// rehydration (it does `Object.entries(provided.tags ?? {})`), so `provided`
|
||||
// must be an object — a bare `{ queries, mutations }` makes it crash on
|
||||
// `provided.tags` of undefined. Always present; empty objects are valid.
|
||||
provided: { tags: Record<string, unknown>; keys: Record<string, unknown> };
|
||||
}
|
||||
|
||||
export const rehydrateApi = createAction<RehydrateApiPayload>(REHYDRATE_API);
|
||||
|
||||
Reference in New Issue
Block a user