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

MaxListenersExceededWarning: Possible EventEmitter memory leak detected #181

Open
fabiansperber opened this issue Feb 25, 2021 · 5 comments

Comments

@fabiansperber
Copy link

In class RedisClient this._redisMock.on('message', (ch, msg) => this._message(ch, msg)); the callback needs to be stored and used for removeListener later in quit(). Right now you are trying to remove a different listener (which wasn't registered) as these are two separate anonymous functions

@fabiansperber
Copy link
Author

Ok, nevermind?! I had a leak of the client in one of my tests. It seems to work now. Still I believe one would need to store the anonymous arrow function for later removal, but I don't understand why it work nevertheless..
You may just close this if it's a non-issue

@baflo
Copy link

baflo commented Apr 21, 2021

I have the same problem. I searched for places where the client would leak, but was successful :/

This snippet is enough to trigger the error message:

Array.from({ length: 11 }).forEach(() => require("redis-mock").createClient())

// (node:7720) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [RedisMock]. Use emitter.setMaxListeners() to increase limit

@baflo
Copy link

baflo commented Apr 21, 2021

And quitting the client does not help, either:

Array.from({ length: 11 }).forEach(() => require("redis-mock").createClient().quit());

@khoirulamri
Copy link

Any update on this?

@arovetto
Copy link

arovetto commented Feb 8, 2023

Any update?

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

4 participants