When creating 11 producer queues with the following configuration I'm seeing the MaxListenersExceededWarning in node 8.9.1.
(node:25043) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
(node:25043) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 ready listeners added. Use emitter.setMaxListeners() to increase limit
(node:25043) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
These queues are only meant to be producer queues, to push new jobs into the queue, not worker queues, so the overhead should be minimized.
I think this happens because of two things:
- the
Queue class is a subclass of Emitter https://github.com/bee-queue/bee-queue/blob/master/lib/queue.js#L13
- somewhere in the
Queue instantiation process bee-queue is attaching event handlers to the 'ready' and 'error' events.
Things I can't figure out:
- Where is number 2 happening?
- Is
Queue correctly removing event handlers when necessary
- Is this a warning that is expected to show up?
It seems reasonable that on a webserver a user of bee-queue would want to instantiate > 10 producer queues. In this reasonable usage of the library I would not expect to get a node warning.
const Redis = require('redis')
const Queue = require('bee-queue')
const redis = Redis.createClient('redis://localhost:6379')
const sharedConfig = {
redis,
getEvents: false,
isWorker: false
}
const queueNames = ['queue-1', 'queue-2', 'queue-3', 'queue-4', 'queue-5', 'queue-6', 'queue-7', 'queque-8', 'queue-9', 'queue-10', 'queue-11']
queueNames.forEach((queueName) => {
const queue = new Queue(queueName, sharedConfig)
console.log('queue created', queue.name)
})

When creating 11 producer queues with the following configuration I'm seeing the MaxListenersExceededWarning in node 8.9.1.
These queues are only meant to be producer queues, to push new jobs into the queue, not worker queues, so the overhead should be minimized.
I think this happens because of two things:
Queueclass is a subclass ofEmitterhttps://github.com/bee-queue/bee-queue/blob/master/lib/queue.js#L13Queueinstantiation process bee-queue is attaching event handlers to the 'ready' and 'error' events.Things I can't figure out:
Queuecorrectly removing event handlers when necessaryIt seems reasonable that on a webserver a user of bee-queue would want to instantiate > 10 producer queues. In this reasonable usage of the library I would not expect to get a node warning.