fix(cron): correctly compute the delay
This commit is contained in:
parent
fd4504f0ee
commit
867c9ea66c
@ -9,7 +9,7 @@ class Job {
|
||||
if (scheduledRun) {
|
||||
fn()
|
||||
}
|
||||
this._timeout = setTimeout(wrapper, schedule.next() - Date.now(), true)
|
||||
this._timeout = setTimeout(wrapper, schedule._nextDelay(), true)
|
||||
}
|
||||
this._fn = wrapper
|
||||
this._timeout = undefined
|
||||
@ -44,6 +44,11 @@ class Schedule {
|
||||
}
|
||||
return dates
|
||||
}
|
||||
|
||||
_nextDelay () {
|
||||
const now = DateTime.fromObject(this._dateTimeOpts)
|
||||
return next(this._schedule, now) - now
|
||||
}
|
||||
}
|
||||
|
||||
export const createSchedule = (...args) => new Schedule(...args)
|
||||
|
Loading…
Reference in New Issue
Block a user