I'm stucking with this issue in my Production server. When adding a job to queue, sometimes It throws an error "Cannot read property 'id' of undefined", I was using Bull Board to retry several times and it's work. I have double-checked my code and logging, so this exception is not from my code.
TypeError: Cannot read property 'id' of undefined
at PayrollService.sendSystemEmailWithQueue (/app/dist/modules/payroll/payroll.service.js:60:106)
at handlers.<computed> (/app/node_modules/bull/lib/queue.js:663:42)
at Queue.processJob (/app/node_modules/bull/lib/queue.js:1098:22)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Bull version
I'm using node v12.20.1, @nestjs/bull ^0.4.1, Redis 6.0.5. I have tried both 0.4.1 and 0.3.1, but same issue.
I notice in your screenshot your job function seems to be both using a done
callback and returning a promise. I don't know if this is related to your id
issue or not, but it should only be doing one or the other - either use a regular function and call done()
, or return a promise, but not both.
The backtrace does pretty directly point to your code, as well - are you certain the code you are looking at is the same version that is running?