From f80b3305a7a98222ec3265b02f550cf69fac4631 Mon Sep 17 00:00:00 2001 From: b0dea <> Date: Tue, 19 Nov 2024 10:01:00 +0200 Subject: [PATCH] fix: add check for nextRunAt on non-recurrent jobs --- src/pulse/resume-on-restart.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pulse/resume-on-restart.ts b/src/pulse/resume-on-restart.ts index 2d35d6d..1226a6e 100644 --- a/src/pulse/resume-on-restart.ts +++ b/src/pulse/resume-on-restart.ts @@ -31,7 +31,11 @@ export const resumeOnRestart: ResumeOnRestartMethod = function (this: Pulse, res $or: [ { lockedAt: { $exists: true }, - nextRunAt: { $ne: null }, + $or: [ + { nextRunAt: { $lte: now, $ne: null } }, + { nextRunAt: { $exists: false } }, + { nextRunAt: null }, + ], $or: [ { $expr: { $eq: ['$runCount', '$finishedCount'] } }, { $or: [{ lastFinishedAt: { $exists: false } }, { lastFinishedAt: null }] }, @@ -40,7 +44,11 @@ export const resumeOnRestart: ResumeOnRestartMethod = function (this: Pulse, res { lockedAt: { $exists: false }, $or: [{ lastFinishedAt: { $exists: false } }, { lastFinishedAt: null }], - nextRunAt: { $lte: now, $ne: null }, + $or: [ + { nextRunAt: { $lte: now, $ne: null } }, + { nextRunAt: { $exists: false } }, + { nextRunAt: null }, + ], }, ], },