Describe the bug#
The devtools will assume the staleTime from a disabled query and show the data as stale, which differs from how the cache actually behaves (the staleTime of the data is Infinite).
const myEndpoint = () =>
new Promise((res) => setTimeout(res, 5000)).then(() => 'hello world');
function Child() {
useQuery({
queryKey: ['example'],
queryFn: myEndpoint,
staleTime: Infinity,
});
return <div>Child</div>;
}
function App() {
useQuery({
queryKey: ['example'],
queryFn: myEndpoint,
enabled: false,
staleTime: 0,
});
return <Child />;
}
Your minimal, reproducible example#
https://stackblitz.com/edit/vitejs-vite-ff9wjj?file=package.json,src%2Fmain.tsx,src%2FApp.tsx&terminal=dev
Steps to reproduce#
- Open devtools
- Notice that the query is marked as stale
- But that the query does not transition back to the fetching state after window is refocused (showing that the devtools)
Expected behavior#
I expected the devtools to be consistent with the cache behavior.
How often does this bug happen?#
Every time
Screenshots or Videos#
No response
Platform#
- OS: Windows 11
- Browser: Firefox 123
Tanstack Query adapter#
react-query
TanStack Query version#
5.25.0
TypeScript version#
5.2.2
Additional context#
No response
Hey there! Would you be able to share some screenshots or videos? From what I've seen, the devtools seem to accurately reflect that the request is disabled initially, and the data for that request is empty. Then, after the request is triggered and disabled for a second time, it appears disabled, but this time the data shows up because it's already available in the cache