Open fabiansperber opened 3 years ago
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
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 functions