From 78ba2c1fb46e969e25de456308aca60472732e51 Mon Sep 17 00:00:00 2001 From: b0dea <> Date: Tue, 19 Nov 2024 12:54:04 +0200 Subject: [PATCH] fix: revert changes to match 1.6.3, apart of resume on restart --- src/job/index.ts | 4 ++-- test/unit/pulse.spec.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/job/index.ts b/src/job/index.ts index b4af6d1..412217a 100644 --- a/src/job/index.ts +++ b/src/job/index.ts @@ -186,7 +186,7 @@ class Job { attrs: JobAttributes; constructor(options: Modify, { _id?: mongodb.ObjectId }>) { - const { pulse, type, nextRunAt, repeatAt, repeatInterval, lastFinishedAt, ...args } = options ?? {}; + const { pulse, type, nextRunAt, ...args } = options ?? {}; // Save Pulse instance this.pulse = pulse; @@ -211,7 +211,7 @@ class Job { ...attrs, name: attrs.name || '', priority: attrs.priority, - type: type || 'single', + type: type || 'once', // if a job that's non-recurring has a lastFinishedAt (finished the job), do not default nextRunAt to now // only if it will be defaulted either by explicitly setting it or by computing it computeNextRunAt nextRunAt: nextRunAt || new Date(), diff --git a/test/unit/pulse.spec.ts b/test/unit/pulse.spec.ts index b17d288..8d1de9b 100644 --- a/test/unit/pulse.spec.ts +++ b/test/unit/pulse.spec.ts @@ -233,7 +233,7 @@ describe('Test Pulse', () => { test('should resume non-recurring jobs on restart', async () => { const job = globalPulseInstance.create('sendEmail', { to: 'user@example.com' }); - job.attrs.nextRunAt = new Date(Date.now() - 1000); + job.attrs.nextRunAt = new Date(Date.now() - 2000); await job.save(); await globalPulseInstance.resumeOnRestart();