addBulk does not work with repeatable jobs
Created by: jtassin
Description
addBulk function does not work properly for repeatable jobs, the nextRepeatableJob is not invoked for repeatable jobs.
Minimal, Working Test code to reproduce the issue.
(An easy to reproduce test case will dramatically decrease the resolution time.)
The following code :
imgQueue.addBulk([{ data: { img }, opts: {repeatable: { every: 5_000 }}}])
is different than :
imgQueue.add({ img }, {repeatable: { every: 5_000 }})
In the add code we have this behaviour once the job is created :
if (opts.repeat) {
return this.isReady().then(() => {
return this.nextRepeatableJob(name, data, opts, true);
});
}
It is missing in the addBulk function.
Solutions
I'm OK to fix it. Here are two possible solutions :
- forbid addBulk for repeatable jobs it could sounds weird to bulk add repeatable jobs, but it is kind of breaking
- call
nextRepeatableJobfor each repeatable jobs of the batch once created. Bad for perfs but still better than multiple adds
which one do you prefer ?
Bull version
3.14
Additional information
Thx for your lib :)