Skip to content

Commit

Permalink
fix: revert changes to match 1.6.3, apart of resume on restart
Browse files Browse the repository at this point in the history
  • Loading branch information
b0dea committed Nov 19, 2024
1 parent c3f63fd commit 78ba2c1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/job/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class Job<T extends JobAttributesData = JobAttributesData> {
attrs: JobAttributes<T>;

constructor(options: Modify<JobAttributes<T>, { _id?: mongodb.ObjectId }>) {
const { pulse, type, nextRunAt, repeatAt, repeatInterval, lastFinishedAt, ...args } = options ?? {};
const { pulse, type, nextRunAt, ...args } = options ?? {};

// Save Pulse instance
this.pulse = pulse;
Expand All @@ -211,7 +211,7 @@ class Job<T extends JobAttributesData = JobAttributesData> {
...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(),
Expand Down
2 changes: 1 addition & 1 deletion test/unit/pulse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ describe('Test Pulse', () => {

test('should resume non-recurring jobs on restart', async () => {
const job = globalPulseInstance.create('sendEmail', { to: '[email protected]' });
job.attrs.nextRunAt = new Date(Date.now() - 1000);
job.attrs.nextRunAt = new Date(Date.now() - 2000);
await job.save();

await globalPulseInstance.resumeOnRestart();
Expand Down

0 comments on commit 78ba2c1

Please sign in to comment.