T
TanStack2y ago
national-gold

Are errors cached in react-query?

Say i have a query in my component. and for some reason it returns an error. i see that if i travel back to that component, a request is not remade, even though my staleTime is set to 0. does that make sense? i thought that errors aren't saved into cache, and hence the query would be refetched?
6 Replies
flat-fuchsia
flat-fuchsia2y ago
errors are indeed refetched and not cached, so if you return a rejected promise from the queryFn, the next time you get to it, yo ushould see a refetch
national-gold
national-goldOP2y ago
weird, it's not refetching for me this is my global config:
queries: {
gcTime: Infinity,
retry: false,
refetchOnWindowFocus: false
queries: {
gcTime: Infinity,
retry: false,
refetchOnWindowFocus: false
im a bit dumbfounded tbh, hadn't found any reason it wouldn't refetch
flat-fuchsia
flat-fuchsia2y ago
show a reproduction ?
national-gold
national-goldOP2y ago
i.e a video?
flat-fuchsia
flat-fuchsia2y ago
no, a codesandbox 😂
national-gold
national-goldOP2y ago
will try a sandbox and see if it reproduces thanks ❤️ A sandbox works as you say, probably something with my setup gonna try and research turned out i used a "tabs" component which didn't actually unmounted a component once it's not displayed, so the hooks weren't called again. thanks for the help

Did you find this page helpful?