-
Notifications
You must be signed in to change notification settings - Fork 111
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
Comments
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.. |
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 |
And quitting the client does not help, either: Array.from({ length: 11 }).forEach(() => require("redis-mock").createClient().quit()); |
Any update on this? |
Any update? |
In class RedisClient
this._redisMock.on('message', (ch, msg) => this._message(ch, msg));
the callback needs to be stored and used forremoveListener
later inquit()
. Right now you are trying to remove a different listener (which wasn't registered) as these are two separate anonymous functionsThe text was updated successfully, but these errors were encountered: