React Query Invalidation Not Working Until Browser DevTools Are Opened
Hello everyone,
I am facing an issue with React Query (
Setup: Query Client wrapped around the entire App.
defaultOptions:
-
-
-
-
-
Issue:
Whenever I call
This bug is new to me—I’ve used React Query this way many times before, and invalidation always worked as expected.
Here’s a minimal example focusing on the issue:
Key Observations:
- The console logs confirm that
- Queries do not refetch until I manually open the browser DevTools.
- The issue happens with any query key, not just
- This is a new issue for me—I have used this setup before without problems.
Has anyone encountered this before? Any idea why this happens? Would appreciate any insights!
I am facing an issue with React Query (
@tanstack/react-query v5.69.0) where query invalidation does not work for any query key until I open the browser DevTools. Setup: Query Client wrapped around the entire App.
defaultOptions:
-
staleTime: 5 minutes -
gcTime: 60 minutes -
cacheTime: 60 minutes -
refetchOnWindowFocus: true -
refetchOnMount: true Issue:
Whenever I call
queryClient.invalidateQueries({ queryKey, ...filters }, options), the query does not refetch immediately. This happens with any query key I try. However, as soon as I open the browser DevTools, the refetch is triggered. It seems like React Query is not recognizing the invalidation unless DevTools are open. This bug is new to me—I’ve used React Query this way many times before, and invalidation always worked as expected.
Here’s a minimal example focusing on the issue:
Key Observations:
- The console logs confirm that
invalidateQueries() is being called. - Queries do not refetch until I manually open the browser DevTools.
- The issue happens with any query key, not just
"Goals". - This is a new issue for me—I have used this setup before without problems.
Has anyone encountered this before? Any idea why this happens? Would appreciate any insights!