AC3: Memory leak in mutation
retains context
object in memory on mutation failure
#7160
Labels
Milestone
mutation
retains context
object in memory on mutation failure
#7160
Intended outcome:
Object passed as
context
tomutate
method should be released when Promise is settled, instead of being retrained in memory.The
MutationStore
holds a reference to an Error forever, it never gets deleted and it's never accessed anywhere in Apollo Client, just in Dev Tools. So I think, ifconnectToDevTools
are disabled (or NODE_ENV === 'production' or typeof window === 'undefined) then storing an Error in
MutationStore` no longer makes sense.Actual outcome:
context
object is retained in memory by AC3.How to reproduce the issue:
Use
mutate
withcontext
set. Apollo keeps reference to that object even when mutation is done, and promise is settled (and all references has been destructed).You can find a complete reproduction (as a Jest test) here:
https://github.com/dotansimha/apollo-very-pessimism/tree/mutation
Instruction:
I also used
patch-package
that represents my PR with a fix, to enable it, please modifypackage.json
And run
Versions
The text was updated successfully, but these errors were encountered: