-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Describe the bug
When invalidating/refetching a query without internet connection, the corresponding promises don't resolve until the connection reestablishes and the query itself resolves.
Your minimal, reproducible example
Steps to reproduce
- Use the provided Code Sandbox.
- Mock offline behavior using React Query Devtools.
- Click on Invalidate/Refetch buttons.
- Understand that the promises aren't resolving. You can refer to the logs in console.
- Disable mocking offline behavior.
- Understand that the promises now resolve.
Expected behavior
I suspect invalidateQueries to only mark queries as stale which is also what Query Invalidation documentation explains. This can lead to refetching of queries but invalidateQueries isn't bound to refetching or its success. In so far, invalidateQueries should resolve after having marked the query as stale. Since I understand refetch just as a more 'aggressive' invalidateQueries, it should behave the same.
How often does this bug happen?
Only the first time when fetching without internet. Fetching again while the previous promise still isn't resolving, results in a resolved promise.
Screenshots or Videos
No response
Platform
- OS: Linux, Android
- Platform: Browser, React Native
- 110.0.5481.178, 0.68.2
TanStack Query version
4.24.10
TypeScript version
4.3.5
Additional context
No response