-
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
Query not being cleaned up when on Strict Mode #8011
Comments
Note that this doesn't happen in production build, when strict mode is noop. |
Might be related to #7952 (comment) |
Having the same issue on Strict mode and getting the "dependencies": {
"@apollo/client": "^3.3.17",
"graphql": "^15.5.0",
"react": "^17.0.0",
"react-dom": "^17.0.0",
"react-router-dom": "^5.2.0",
"typescript": "^4.1.2",
"vite": "^2.3.0"
} |
Having this warnings in "@apollo/client": "^3.3.19" |
This should be fixed with |
While the warning is gone, I still have the issue that the queries are not cleaned up with Looking at the active queries with the dev tools, it seems like a query is spawned twice, one with "__typename" queried as well and one without. But only the query with "__typename" is cleaned up. Without strict mode, only a query with "__typename" is spawned (and cleaned up). |
I just wanted to note here for anyone using react-router's history to navigate to another page after deleting a document that the memory leak warning went away when I updated to the latest version of @apollo/client (for me this was "@apollo/client": "^3.5.10"). I was previously using version 3.1.4. I needed to restart my application for this to take effect. |
Intended outcome:
When unmounting a component that uses
useQuery
, it should clean up even when wrapped by Strict Mode.Actual outcome:
Updating the cache on which an unmount component depends, generates a react warning about memory leak.
How to reproduce the issue:
https://codesandbox.io/s/nifty-heyrovsky-5cf34
1- Click on "John Smith" and wait for the page to load
2- Click on "Back"
3- Click on "Like" button right by "John Smith"
4- Observe the warning in the console.
Checking on Apollo DevTools, there seems to be more active queries than it should have been after a few times reproducing the issue.
Compared to when Strict mode is not active:
Versions
The text was updated successfully, but these errors were encountered: