MaxListenersExceededWarning
nico3dfx opened this issue · comments
Hi,
I have the MaxListenersExeededWarning warning with my configuration.
(node:23904) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 newListener listeners added to [Broker]. Use emitter.setMaxListeners() to increase limit
at _addListener (events.js:390:17)
at Broker.addListener (events.js:406:10)
at forwardEmitter (c:\laragon\www\rascal-mc\node_modules\forward-emitter\index.js:18:8)
at c:\laragon\www\rascal-mc\node_modules\rascal\lib\amqp\tasks\initVhosts.js:15:9
at c:\laragon\www\rascal-mc\node_modules\rascal\lib\amqp\Vhost.js:70:14
at c:\laragon\www\rascal-mc\node_modules\async\dist\async.js:2022:31
at wrapper (c:\laragon\www\rascal-mc\node_modules\async\dist\async.js:271:20)
at c:\laragon\www\rascal-mc\node_modules\async\dist\async.js:1963:19
at wrapper (c:\laragon\www\rascal-mc\node_modules\async\dist\async.js:271:20)
at replenish (c:\laragon\www\rascal-mc\node_modules\async\dist\async.js:441:29)
(node:23904) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 removeListener listeners added to [Broker]. Use emitter.setMaxListeners() to increase limit
at _addListener (events.js:390:17)
at Broker.addListener (events.js:406:10)
at forwardEmitter (c:\laragon\www\rascal-mc\node_modules\forward-emitter\index.js:22:8)
at c:\laragon\www\rascal-mc\node_modules\rascal\lib\amqp\tasks\initVhosts.js:15:9
at c:\laragon\www\rascal-mc\node_modules\rascal\lib\amqp\Vhost.js:70:14
at c:\laragon\www\rascal-mc\node_modules\async\dist\async.js:2022:31
at wrapper (c:\laragon\www\rascal-mc\node_modules\async\dist\async.js:271:20)
at c:\laragon\www\rascal-mc\node_modules\async\dist\async.js:1963:19
at wrapper (c:\laragon\www\rascal-mc\node_modules\async\dist\async.js:271:20)
at replenish (c:\laragon\www\rascal-mc\node_modules\async\dist\async.js:441:29)
Environment
My config (today, the number will increase) has 32 vhosts each with:
- 1 connection (same URL for all vhosts)
- 100 queues
- 100 bindings
- 100 subscriptions
No problem when the warmup process complete: Rabbit has all the queues with the relative consumer.
Thanks,
Nico.
Hi @nico3dfx,
I will try to reproduce. Can you confirm your node.js and rascal version please?
Hi @nico3dfx,
I will try to reproduce. Can you confirm your node.js and rascal version please?
Node @ 14.16.1
Rascal @ 15.0.0
Thank you @cressie176
I've been able to reproduce. The warning is caused because Rascal uses the forward-emitter package to forward events from each vhost to the broker object, so that when an "error" event is emitted from a vhost (which isn't exposed by Rascal), it is re-emitted on the broker, where it can be handled.
Confusingly forward-events library doesn't work by forwarding events at all. Instead it registers a newListener event handler on the broker, then when an event handler is added, duplicates it on the vhost.
This means that each new vhost adds an "newListener" handler, and after the 10th vhost, node reports the MaxListenersExceededWarning.
I'll increase the threshold to Math.max(10, numberOfVhosts)
Published as rascal@15.0.1