Skip to content
This repository was archived by the owner on Jun 18, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: '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();
Expand Down
Loading