File tree 3 files changed +3
-8
lines changed
3 files changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ export class Job<DATA = unknown | void> {
62
62
...args ,
63
63
// Set defaults if undefined
64
64
priority : parsePriority ( args . priority ) ,
65
- nextRunAt : args . nextRunAt || new Date ( ) ,
65
+ nextRunAt : args . nextRunAt === undefined ? new Date ( ) : args . nextRunAt ,
66
66
type : args . type
67
67
} ;
68
68
}
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ export class JobProcessingQueue {
102
102
| undefined ;
103
103
} ,
104
104
handledJobs : IJobParameters [ '_id' ] [ ]
105
- ) : ( JobWithId & { attrs : IJobParameters & { nextRunAt : Date } } ) | undefined {
105
+ ) : ( JobWithId & { attrs : IJobParameters & { nextRunAt ? : Date | null } } ) | undefined {
106
106
const next = ( Object . keys ( this . _queue ) as unknown as number [ ] ) . reverse ( ) . find ( i => {
107
107
const def = this . agenda . definitions [ this . _queue [ i ] . attrs . name ] ;
108
108
const status = jobStatus [ this . _queue [ i ] . attrs . name ] ;
@@ -116,11 +116,6 @@ export class JobProcessingQueue {
116
116
! handledJobs . includes ( this . _queue [ i ] . attrs . _id ) &&
117
117
( ! status || ! def . concurrency || status . running < def . concurrency )
118
118
) {
119
- if ( ! this . _queue [ i ] . attrs . nextRunAt ) {
120
- // eslint-disable-next-line no-console
121
- console . log ( 'this._queue[i]' , this . _queue [ i ] . attrs ) ;
122
- throw new Error ( 'no nextRunAt date' ) ;
123
- }
124
119
return true ;
125
120
}
126
121
return false ;
Original file line number Diff line number Diff line change @@ -409,7 +409,7 @@ export class JobProcessor {
409
409
410
410
// If the 'nextRunAt' time is older than the current time, run the job
411
411
// Otherwise, setTimeout that gets called at the time of 'nextRunAt'
412
- if ( job . attrs . nextRunAt <= now ) {
412
+ if ( ! job . attrs . nextRunAt || job . attrs . nextRunAt <= now ) {
413
413
log . extend ( 'jobProcessing' ) (
414
414
'[%s:%s] nextRunAt is in the past, run the job immediately' ,
415
415
job . attrs . name ,
You can’t perform that action at this time.
0 commit comments