MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 job ttl exceeded listeners added. Use emitter.setMaxListeners() to increase limit
- Dominant language
- JavaScript
- Stars
- 9.4k
- Forks
- 858
- PR merge metrics
- No merged PRs in 30d
Description
I'm getting `(node:38) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 job ttl exceeded listeners added. Use emitter.setMaxListeners() to increase limit`
my Kue implementation:
```
const kue = require('kue')
const $raven = require('./Raven')
const $jobs = require('../config/jobs')
const queue = kue.createQueue({
// supress job level events
jobEvents: false,
// config redis connection
redis: {
host: process.env.REDIS_HOST || '127.0.0.1',
port: process.env.REDIS_PORT || 6379
}
})
queue.on('error', function (err) {
console.log('Kue error \n', err)
$raven.captureException(err)
})
// register jobs
Object.keys($jobs).forEach(name => {
queue.process(name, $jobs[name])
})
module.exports = queue
```
a job declaration example
```
'supplier-notify-created': async function (job, done) {
try {
console.log('notifying supplier was created...')
let { message } = job.data
await $axios({
method: 'POST',
url: $api.crmSupplierWebhook(),
data: {
message
}
})
console.log('successfully notified supplier was created')
done()
} catch (err) {
console.log('error notifying supplier created', err)
$raven.captureException(err)
done(err)
}
}
```
job registration
```
const supplierNotifyUpdated = function (req, res) {
let { message, user, supplierUuid } = req.body
if (!message || !user || !supplierUuid) {
throw new BadRequestError('Missing Parameters')
}
$kue.create('supplier-notify-updated', { message, user, supplierUuid })
.priority('critical')
.attempts(3)
.removeOnComplete(true)
.save()
console.log('created supplier update notification job')
res.json('ok')
}
```
whole project here: https://github.com/AddToEvent/JobProcessor
Kue version: `0.11.6`
I'm using docker images to launch my app
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the warning with the supplied JobProcessor queue setup and Kue 0.11.6, focusing on queue.process registration and the job TTL listeners named in the warning. Inspect the Kue and Node.js EventEmitter behavior involved, then verify that the warning no longer appears under the same workload without simply increasing the listener limit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js, redis
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100