Skip to content
This repository was archived by the owner on Oct 27, 2025. It is now read-only.

Commit 97ee2d5

Browse files
author
b0dea
committed
Avoid double updating on the non-recurring jobs vs recurring jobs search in resumeOnRestart
1 parent c8e87f0 commit 97ee2d5

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/pulse/resume-on-restart.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,26 @@ export const resumeOnRestart: ResumeOnRestartMethod = function (this: Pulse, res
2424
this._collection
2525
.updateMany(
2626
{
27-
$or: [
27+
$and: [
28+
{ repeatInterval: { $exists: false } },
29+
{ repeatAt: { $exists: false } },
2830
{
29-
lockedAt: { $exists: true },
30-
nextRunAt: { $ne: null },
3131
$or: [
32-
{ $expr: { $eq: ['$runCount', '$finishedCount'] } },
33-
{ $or: [{ lastFinishedAt: { $exists: false } }, { lastFinishedAt: null }] },
32+
{
33+
lockedAt: { $exists: true },
34+
nextRunAt: { $ne: null },
35+
$or: [
36+
{ $expr: { $eq: ['$runCount', '$finishedCount'] } },
37+
{ $or: [{ lastFinishedAt: { $exists: false } }, { lastFinishedAt: null }] },
38+
],
39+
},
40+
{
41+
lockedAt: { $exists: false },
42+
$or: [{ lastFinishedAt: { $exists: false } }, { lastFinishedAt: null }],
43+
nextRunAt: { $lte: now, $ne: null },
44+
},
3445
],
3546
},
36-
{
37-
lockedAt: { $exists: false },
38-
$or: [{ lastFinishedAt: { $exists: false } }, { lastFinishedAt: null }],
39-
nextRunAt: { $lte: now, $ne: null },
40-
},
4147
],
4248
},
4349
{

0 commit comments

Comments
 (0)