You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you use the every option in BullMQ, it schedules jobs based on fixed time intervals, which might seem a bit counterintuitive initially.
...
For example, if you set the job to repeat monthly, normally it would wait to start until the first second of the next month. If you add the job mid-month, it would not start until the beginning of the following month. Using immediately ensures the first instance of the job runs as soon as it’s added, bypassing the wait until the scheduled interval begins.
Then we have the example:
awaitmyQueue.upsertJobScheduler('immediate-job',{every: 86400000,// once a dayimmediately: true,// execute the first one immediately},{name: 'instant-job',data: {message: 'Immediate start'},},);
Running the above code results in the Using option immediately with every does not affect the job's schedule. Job will run immediately anyway. warning, coming from here:
"Using option immediately with every does not affect the job's schedule. Job will run immediately anyway.",
);
}
This is clearly contradicting what the documentation says.
What I wanted to do is to schedule a repeating job that runs now and then 24 hours later and another 24 hours later and so on.
It seems like having the below code accomplishes this goal (at least running this, my job ran immediately), even though according to the documentation, this would first run at the first second of the next day.
awaitmyQueue.upsertJobScheduler('my-job',{every: 86400000,// once a day});
Is my experimental understanding correct, that every causes the job to run now and repeats after every interval?
If so, can the documentation be updated to reflect the actual behavior?
The text was updated successfully, but these errors were encountered:
We deprecated "immediately" on repeat recently but have not yet updated the documentation, thank you for posting this to remind me. The current behaviour is as if immediately is always true, if you need a different behaviour you can use the much more flexible cron expressions or custom expressions.
Is my experimental understanding correct, that every causes the job to run now and repeats after every interval?
@manast Could you please clarify this as well? As per the documentation, every should be running every x seconds. For example, if it's 60000, then the start of every minute. However, for me it's working like an interval; when the job is added at 00:00:15, the next execution is at 00:01:15 instead of 00:01:00.
Documentation: https://docs.bullmq.io/guide/job-schedulers/repeat-options#immediately
Then we have the example:
Running the above code results in the
Using option immediately with every does not affect the job's schedule. Job will run immediately anyway.
warning, coming from here:bullmq/src/classes/job-scheduler.ts
Lines 62 to 66 in 7a37f09
This is clearly contradicting what the documentation says.
What I wanted to do is to schedule a repeating job that runs now and then 24 hours later and another 24 hours later and so on.
It seems like having the below code accomplishes this goal (at least running this, my job ran immediately), even though according to the documentation, this would first run at the first second of the next day.
every
causes the job to run now and repeats after every interval?The text was updated successfully, but these errors were encountered: