-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[BUG] useQuery race-condition bug #10587
Comments
Hey @hakonxxx 👋 I tried to reproduce this as best I could given the same I made an effort to:
As you can see, the cache appears to merge all the fields correctly, even as requests complete over time. Would you be willing to try and provide a runnable example that demonstrates failing behavior? Given the information I have here, I'm not sure I have enough to go on to figure out what might be happening. |
Hi @jerelmiller , thx for reply~~ i have fork a new sandbox, changes:
refresh the page several times, and you will see some situations like: BTW:
|
I doubt the usage of multi queries with overlap fields, but sometimes we just do it indeed :( So back to this case, maybe there are better solutions instead of just discarding the maybe-staled response(what a waste and may confuse users and FE), maybe we could partially update the cache? Also there is bug even just discarding the response(sometimes we discarded, sometimes not), because of |
Adding a Replay of the problem happening here. |
@hakonxxx not sure if this is helpful, but your reproduction bug seems to get fixed if you change |
Yes:
So the behavior seems more weird... |
apollo-client/src/core/ObservableQuery.ts Line 844 in f75de97
This here is the culprit. We have a chain of That said, having identified the reason and knowing how to fix it are two different things. I'm gonna dig a bit deeper. |
I think two things need to consider:
|
Oh, we'll definitely be discussing this internally to see what's going on, this is an excellent reproduction of a race condition that should (as far as I'm concerned) not be happening. Thank you so much for this reproduction! |
seems @3.7.11 fix this bug codesandbox, appreciated~ cc @phryneas |
Thanks @hakonxxx 🙏🏻 closing this as resolved 🚀 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
useQuery race condition bug, not update cache when one of multi queries done which refer same cacheId.
Root Cause
Reproduction
Suggested
Usage
Expected Behavior
After all requests done, the cache should be the merge of doc1, doc2 and doc3.
Actual Behavior
After all requests done, the cache could be any combinations of doc1/doc2/doc3.
Versions
@apollo/client: 3.6.9
The text was updated successfully, but these errors were encountered: