{"record":{"id":"7a19293eef6b5124","repo":"TanStack/query","slug":"provided-storage-does-not-implement-entries-meth-7a1929","errorCode":null,"errorMessage":"Provided storage does not implement `entries` method. Restoration of all stored entries is not possible without ability to iterate over storage items.","messagePattern":"Provided storage does not implement `entries` method\\. Restoration of all stored entries is not possible without ability to iterate over storage items\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/query-persist-client-core/src/createPersister.ts","lineNumber":316,"sourceCode":"              if (persistedQuery.queryHash !== hashKey(queryKey)) {\n                continue\n              }\n            } else if (!partialMatchKey(persistedQuery.queryKey, queryKey)) {\n              continue\n            }\n          }\n\n          queryClient.setQueryData(\n            persistedQuery.queryKey,\n            persistedQuery.state.data,\n            {\n              updatedAt: persistedQuery.state.dataUpdatedAt,\n            },\n          )\n        }\n      }\n    } else if (process.env.NODE_ENV === 'development') {\n      throw new Error(\n        'Provided storage does not implement `entries` method. Restoration of all stored entries is not possible without ability to iterate over storage items.',\n      )\n    }\n  }\n\n  async function removeQueries(\n    filters: Pick<QueryFilters, 'queryKey' | 'exact'> = {},\n  ): Promise<void> {\n    const { exact, queryKey } = filters\n\n    if (storage?.entries) {\n      const entries = await storage.entries()\n      const storageKeyPrefix = `${prefix}-`\n      for (const [key, value] of entries) {\n        if (key.startsWith(storageKeyPrefix)) {\n          if (!queryKey) {\n            await storage.removeItem(key)\n            continue","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/TanStack/query/blob/159982c80b844487054155c38ffc760fe4208daf/packages/query-persist-client-core/src/createPersister.ts#L298-L334","documentation":"Dev-only error from `restoreQueries` in `createPersister`. Restoring all queries needs to enumerate stored keys; without `storage.entries()` the bulk restore cannot proceed, so in development it throws. Filtered restores by `queryKey` would still work via direct key reads, but the unconditional path in this function requires iteration.","triggerScenarios":"Calling `restoreQueries(queryClient)` (or via the persist client plugin's restore-on-init) when the storage lacks `entries()`; using a storage adapter that only supports key-based access.","commonSituations":"React Native `AsyncStorage`; custom AsyncStorage adapters; minimal test stubs; legacy `localStorage` shims in older browsers/Node.","solutions":["Add `entries()` to the storage adapter returning `[key, value]` pairs.","Switch to a storage that natively supports enumeration (`localforage`, `Map`).","If only specific keys need restoring, restore them manually via `retrieveQuery` per key instead of bulk `restoreQueries`.","Verify in production builds the throw is skipped (dev-only) and decide whether silent skip is acceptable."],"exampleFix":"// before\nconst persistor = new PersistQueryClientClient({ queryClient, persister: createPersister({ storage: asyncStorage }) })\nawait persistor.restore()\n// after\nconst storage = { ...asyncStorage, entries: async () => { const keys = await asyncStorage.getAllKeys(); return Promise.all(keys.map(async k => [k, await asyncStorage.getItem(k)])) } }\nconst persistor = new PersistQueryClientClient({ queryClient, persister: createPersister({ storage }) })","handlingStrategy":"validation","validationCode":"function assertCanRestore(storage: any) {\n  if (!storage || typeof storage.entries !== 'function') {\n    throw new Error('restoreQueries needs storage.entries()')\n  }\n}","typeGuard":"const canEnumerate = (s: any): s is { entries(): Promise<Iterable<[string, any]>> } =>\n  !!s && typeof s.entries === 'function'","tryCatchPattern":"try { await persister.restoreQueries(queryClient) } catch (e) { if (/entries method/.test((e as Error).message)) console.warn('restore skipped:', e.message) }","preventionTips":["Use a storage with native `entries()` support.","If only specific keys matter, restore them via `retrieveQuery` per key.","Test the adapter's `entries()` contract before integration.","Remember the throw is dev-only; decide whether production no-op is acceptable."],"tags":["persister","storage","restore","validation","dev-only"],"backgroundTag":null,"analyzedSha":"159982c80b844487054155c38ffc760fe4208daf","analyzedAt":"2026-08-12T16:21:52.822Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}