BUG: Inconsistent delay property
Created by: tsebas
Description
When a job is created with queue.add
with the delay param in opts, the resulting job has the delay
property with the assigned value. However, in the queue processor, the job that comes in has the corret delay value in the opts object, whilst the delay property has 0.
Minimal, Working Test code to reproduce the issue.
const bull = require('bull');
const q = new bull('queue', {
redis: {host: 'localhost', port: 6380, password: null},
});
q.process(job => {
console.log('process', job.delay, job.opts.delay);
});
q.add({}, {delay: 1}).then(job => console.log('add', job.delay, job.opts.delay));
Bull version
"bull": "^3.14.0"
Additional information
The above code generates the following output. I added a console.log on Job.fromJSON
function in bull/lib/job.js:576
add 1 1
json { name: '__default__',
data: '{}',
opts: '{"delay":1,"attempts":1,"timestamp":1598439486198}',
timestamp: '1598439486198',
delay: '0',
priority: '0',
processedOn: '1598439486213' }
process 0 1
I didn't fully debug the code to understand where the most appropriate fix would go, but I suspect the only actually problematic line is bull/lib/job.js:588 job.delay = parseInt(json.delay);
. Before this line, the job.delay
is correctly built form the constructor.