-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
addBulk does not work with repeatable jobs #1731
Comments
Looks like similar bug #1761 |
I also want to add that const jobs = [
{ name: 'cron_job_hourly', opts: { repeat: { cron: '0 * * * *' } } },
{ name: 'cron_job_daily', opts: { repeat: { cron: '0 0 * * *' } } },
]
queue.addBulk(jobs); If you have code like this, then two unexpected issues will happen:
Solution would be to either add support for bulk adding repeatable jobs to a queue, or disable the feature entirely for repeatables to avoid confusion. |
addBulk does not support repeatable jobs, and I do not think it is worth implementing. The idea of addBulk is to remove overhead when adding huge amounts of jobs, it does not make so much sense for repeatable jobs which usually are not so many. |
Makes sense to me - might be worth adding some kind of type check to stop jobs being added like this, or at least adding to declaration or documentation that it is not supported |
+1 for type check and documentation
Yes, |
fixed with taskforcesh/bullmq#544 |
I innocently tried to use addBulk to add a bunch of jobs with repeat options and was confused why it didn't work. Turns out it's simply not supported as concluded in OptimalBits/bull#1731 Hopefully this little update to the typings avoids someone else hitting the same issue I did
It is not just about performance, sometimes we need atomicity. |
Description
addBulk
function does not work properly forrepeatable
jobs, thenextRepeatableJob
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 :
is different than :
In the
add
code we have this behaviour once the job is created :It is missing in the
addBulk
function.Solutions
I'm OK to fix it. Here are two possible solutions :
nextRepeatableJob
for each repeatable jobs of the batch once created. Bad for perfs but still better than multiple addswhich one do you prefer ?
Bull version
3.14
Additional information
Thx for your lib :)
The text was updated successfully, but these errors were encountered: