-
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
React.StrictMode and useQuery causing double active queries #9903
Comments
We just ran into this as well. Not just duplicate, but any permutation previously mounted queries apparently stay active and are triggered by Is there some sort of cleanup that Apollo should be doing to be compatible with |
I am also experiencing this problem. For me the issue causes a problem with the first render of useQuery having a pollInterval set with the initial variables and then after changing the variables such that the pollInterval gets set to 0, I get the new data back, but it shortly gets replaced by the original polling query which is definitely the wrong data. |
Hey there, We do delay the "tear down" for a short moment, so the next request can latch onto the existing network request and doesn't trigger another network request, and we generally deduplicate network requests. Unfortunately, all the descriptions you are giving us here are very vague and will not help us to reproduce the issue. I also believe that the three of you (@Vuliniar , @kainosnoema , @majjhima ) are experiencing three independent problems here. Could you please provide us with minimal reproductions of your issues so we can take a look at them? |
Equal if query with suspense... Only appear in StrictMode not in prod... |
Hey @damikun 👋 Would you be able to provide a reproduction and a more detailed description of what you're seeing? For |
I'm seeing the same issue. I wouldn't say I'm doing anything special besides quite standard Apollo Client usage. Just look at the logs in the Chrome dev tools. We only have a single query in the whole application, still looking into |
@levrik did you mean to share a link to a modified reproduction? That is the unmodified error reproduction template. And executing |
@phryneas Already updated the link. CodeSandbox's share feature gave me the link of the template for some reason until I did a full reload of the page. |
Ah, gotcha. Yes, there are two queries there, but only one of them is an "active" query, which is what this issue if about. You can see that by calling |
@phryneas That's true but for example as mentioned above Since So either |
Yeah, this is definitely be something to look into, my main point right now is that it's a different issue from this issue, because in the past, actually, both of these queries were "active". Could you please open a new issue so we can track this separately? (This is actually a good reminder to close this issue, since it should have been solved quite a while ago) |
@phryneas I see. Wasn't super clear to me from the issue description that it was really above "active" queries or just queries that seem to be active. Let me file a separate issue. |
Meanwhile I'll close this issue. See you in the new one! |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better. |
Hello,
This issue already exist in opened issues, but I found more problems it causes. In React.Strict mode active queries are getting doubled and leading to very annoying bugs - sometimes even hard to spot and debug.
Here is the example in our codebase:
Outcome: So in active queries we end up having queries which are not indeed active (duplicates)
What it causes? If we by any chance do refetchQueries, it will refetch even the query we don't need (but because it is in active queries apollo refetches it). It leads to some serious bugs - you're requesting one type of data (based on variable) and getting something totally different (so cached objects also get affected, keyargs, etc..).
If we remove React.Strict mode (which I'd argue is bad idea) everything seems to work.
Thank you!
The text was updated successfully, but these errors were encountered: