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

Lazily add process event listener #449

Merged

Conversation

FabienChaynes
Copy link
Contributor

Only attach a listener to process when the cluster mode is used to prevent a memory leak after multiple requires.

The tests are passing, but I'm not familiar with the way the cluster mode is working. So even if it seems ok to me according to the way it's used in example/cluster.js, you might want to double check that I didn't break anything there 🙂

Fixes #448.

@zbjornson
Copy link
Collaborator

Thanks for opening this. Initial 👍 , will review fully this weekend.

Copy link
Collaborator

@zbjornson zbjornson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

@zbjornson zbjornson merged commit 216e2b3 into siimon:master Jul 31, 2021
@zbjornson
Copy link
Collaborator

zbjornson commented Sep 19, 2021

I just realized that this actually broke cluster metrics. (My bad for not catching it.) addListeners() is only called when new AggregatorRegistry() is called, and that's not supposed to be instantiated on workers, only the master. (I'll fix up the example so it follows that pattern.)

I don't see a way to do what you're trying to do here without requiring users to call a setup function explicitly. Being explicit is probably best though.

Working on a patch for v13 and v14 now.

prevent a memory leak after multiple requires.

Ugh, jest.

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

Successfully merging this pull request may close these issues.

Listener added to process even if not using clusters
2 participants