From 867c9ea66ce8aac59528095770481e4e4143b41b Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Tue, 6 Feb 2018 15:28:54 +0100 Subject: [PATCH] fix(cron): correctly compute the delay --- @xen-orchestra/cron/src/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/@xen-orchestra/cron/src/index.js b/@xen-orchestra/cron/src/index.js index dae5c62e8..c599a7297 100644 --- a/@xen-orchestra/cron/src/index.js +++ b/@xen-orchestra/cron/src/index.js @@ -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)