fix(cron): correctly compute the delay

This commit is contained in:
Julien Fontanet 2018-02-06 15:28:54 +01:00
parent fd4504f0ee
commit 867c9ea66c

View File

@ -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)