Open
Description
Describe the bug
When using both persistence and a custom queryKeyHashFn
, the DevTools will crash on initial load with error:
TypeError: Cannot read properties of undefined (reading 'fetchStatus')
at getQueryStatusColor
Busting the cache on each load "fixes" it. And so does removing the custom queryKeyHashFn
.
Just upgraded from v4, and this worked fine then. I also tried with a createSyncStoragePersister, and that works completely fine as well.
Your minimal, reproducible example
https://codesandbox.io/p/devbox/musing-williamson-vgj34y?file=%2Fsrc%2FApp.jsx%3A90%2C29
Steps to reproduce
- Wrap any app in PersistQueryClientProvider with an indexdb persister example from the docs
- Add a custom
queryKeyHashFn
to queryClientdefaultOptions.queries.queryKeyHashFn
. E.g. return(queryKey)=>hashKey(queryKey) + "_test"
- Reload the page
It works when there's no cache being loaded. It doesn't when something is loaded from the cache.
Expected behavior
Devtools should support a custom queryKeyHashFn with async persistence.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
Macos, latest chrome
Tanstack Query adapter
react-query
TanStack Query version
5.22.2
TypeScript version
No response
Additional context
No response