Memory Leak: Mutation + OptimisticResponse makes update function to leak
See original GitHub issueAfter executing a mutation with update
function and optimisticResponse
the update
function is hold in memory forever which leaks other referenced objects.
How to reproduce the issue: https://github.com/kamilkisiela/apollo-optimistic-response-pessimistic-memory-leak
npm install
npm run start
- Open
chrome://inspector
- Connect to a process
- Click play on first breaking point
- On next breaking point, take a snapshot
- Look for
Foo
class
@benjamn I can confirm that Cache.removeOptimistic
is called but Foo
is still there
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Optimistic mutation results - Apollo GraphQL Docs
If our app is wrong (e.g., the GraphQL server returns an unchanged Comment due to an error), the UI will automatically update to...
Read more >graphql after running mutation if I quickly goback to ...
Even if move to another page during mutating, I want to proceed with the update as it is How can I proceed with...
Read more >[React +GraphQL] Using refetchQuery causes memory ...
Error code: Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak...
Read more >Developing a Data Sync Application
Because of this, when mutations that can change query results are performed, the refetchQueries or update options of the mutate method should be...
Read more >vue/apollo-option
Bug Fixes · apollo components registered twice, fix #1336 (3ad3ab3) · change data init, related to #1350 (b94bdf7) · Make calls of the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kamilkisiela I’ve updated the
optimism
library so that it no longer holds ontoentry.args
arrays (see https://github.com/benjamn/optimism/pull/104), so memory leaks related to arguments passed to methods likeexecuteSelectionSet
should no longer be possible.Following your reproduction steps, I no longer see retainment paths for
Foo
objects with lines likeargs in Entry @1663111
(or anything above it).These changes were published in
optimism@0.13.1
and can be tested by running eithernpm i optimism@latest
ornpm i @apollo/client@3.3.0-rc.2
.It might still be worthwhile to evict/forget
Entry
objects associated with optimistic updates that have been rolled back, but I’d want to see some evidence that’s still a problem, now that function arguments are no longer retained.should #7276 be merged into master too? It should minimize amount of potential memory leaks too