Huge slowdown in resolution of job.finished() promise if add called with some delay after process
Created by: pcernek-spare
Description
Create a queue -> add a (trivial) processor function -> wait 100 ms -> add a job -> wait for job.finished()
: takes ~5 seconds
Do the same thing, but remove the "wait 100 ms" step: takes ~ 200 ms
Minimal, Working Test code to reproduce the issue.
index.js
const Queue = require('bull');
const Bluebird = require('bluebird')
const queue = new Queue('myTestQueue')
const delayMs = 100
queue.process((job) => {
return job.data + 1
})
Bluebird.delay(delayMs).then(() => {
queue.add(42).then((job) => {
job.finished().then(process.exit)
})
})
Run time node index.js
: takes ~ 5 s
Set delayMs
to 0 to remove the delay, run the same thing again: takes ~200 ms
Bull version
3.4.2
Additional information
Inserting some print statements suggests that the job gets processed very fast -- the bottleneck seems to be in the job.finished()
promise resolving.