Open justinadkins opened 1 month ago
Hey @justinadkins 👋
Thanks for the really clearly documented issue! I see you are interested in helping out with it, awesome! Are you hoping to create a PR with a fix? If so I'd be happy to help out in any way you might need.
Hey @Josh-Walker-GM! Yes, I'm happy to submit a PR. I think the fix is pretty straight forward.
@justinadkins Are you thinking of using WeakRef to hold the the instance?
@callingmedic911 Just seeing this now, I hadn't considered using WeakRef. I submitted a PR #11699 if you'd like to take a look. I'm jus using a local variable to keep track of the current instance.
What's not working?
With how the provider is currently constructed, a parent re-render will orphan an apollo client instance and create a new one. I believe this causes a memory leak and cache orphaning. I discovered it because of client pollution visible when using Apollo Client's dev tools.
This is due to the lack of memoization where the client is instantiated here.
How do we reproduce the bug?
Force a re-render of a parent of the
RedwoodApolloProvider
, for exampleApp
. Using the Apollo Client devtools, observe a new client instantiation each render.What's your environment? (If it applies)
No response
Are you interested in working on this?