Skip to content
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

Possible memory leak on Client.listeners #106

Open
devunt opened this issue Sep 5, 2024 · 2 comments
Open

Possible memory leak on Client.listeners #106

devunt opened this issue Sep 5, 2024 · 2 comments

Comments

@devunt
Copy link

devunt commented Sep 5, 2024

If an established subscription is disposed by calling its dispose function (which is returned by subscribe method itself), which is pretty common scenario, a memory leak occurs in the Client. A listeners field keep track callbacks which will get called when Client.dispose() method is called, but it doesn't properly clean up the callback if the subscription is disposed individually. This leads to constantly growing Client.listeners array if the subscription is frequently created and disposed through application's lifecycle.

CleanShot 2024-09-05 at 16 52 58

@mokcoo
Copy link

mokcoo commented Oct 30, 2024

I already met this situation, I'm making an subscription when a modal is open and closing that subscription when that modal is closed, and on the backend the pubs is already complaining that too many listeners added to EventEmitter.
image

@mokcoo
Copy link

mokcoo commented Nov 4, 2024

https://www.apollographql.com/docs/apollo-server/data/subscriptions
As said in this doc, we should use the pubsub that was designed for prod env. I use the redis pubs, and then that problem is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants