-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalidate/Refetch Promises not resolving when paused #5054
Comments
That's not true, the docs say two things:
In the code, this is implemented as:
query/packages/query-core/src/queryClient.ts Lines 232 to 245 in a22d056
That's the reason why it returns a
This also doesn't make a lot of sense, conceptually. If right now, the imperative fetch methods work the same as One thing we could think about is returning a resolved promise immediately if you cannot fetch (because you are offline), but are required to (because of query/packages/query-core/src/retryer.ts Lines 212 to 215 in a22d056
This would certainly work for We could make a distinction here with a flag but it's something I'd need to think about |
Okay, so I had the misconception that
is a side note of an effect happening after calling
I understand and yes, I better should have familiarized myself with the source code.
There's obviously a lot in React Query I haven't touched so far. Excuse my yet superficial understanding.
That's basically what I wanted to bring up for discussion. This would certainly help in my case: I'm using the workaround for RefreshControl flickering discussed in #2380 and if the user refreshes when being offline, the indicator doesn't stop until the promise is resolved. After resolving immediately when offline, would the mutation/query still be queued for execution when coming back online or canceled? |
No worries. Thank you for the bug report. You're definitely on to something.
yes, provided that I'm inclined to fix this for |
Sounds good! I'm happy this bug report was somewhat helpful. |
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
https://codesandbox.io/s/react-query-refetch-invalidate-promises-not-resolving-when-paused-hsk41e
Steps to reproduce
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 butinvalidateQueries
isn't bound to refetching or its success. In so far,invalidateQueries
should resolve after having marked the query as stale. Since I understandrefetch
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
TanStack Query version
4.24.10
TypeScript version
4.3.5
Additional context
No response
The text was updated successfully, but these errors were encountered: