Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert changes to match 1.6.3, apart of resume on restart #64

Merged
merged 1 commit into from
Nov 19, 2024
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: '[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
Loading