diff --git a/src/classes/queue-base.ts b/src/classes/queue-base.ts index 3d256dcb52..23bce01593 100644 --- a/src/classes/queue-base.ts +++ b/src/classes/queue-base.ts @@ -14,12 +14,10 @@ export class QueueBase extends EventEmitter { constructor(protected name: string, public opts: QueueBaseOptions = {}) { super(); - this.opts = Object.assign( - { - prefix: 'bull', - }, - opts, - ); + this.opts = { + prefix: 'bull', + ...opts, + }; this.connection = new RedisConnection(opts.connection); this.initializing = this.connection.init(); diff --git a/src/classes/queue-scheduler.ts b/src/classes/queue-scheduler.ts index d3c0fd1c42..0f4a5a12f5 100644 --- a/src/classes/queue-scheduler.ts +++ b/src/classes/queue-scheduler.ts @@ -24,13 +24,8 @@ const MAX_TIMEOUT_MS = Math.pow(2, 31) - 1; // 32 bit signed export class QueueScheduler extends QueueBase { private nextTimestamp = Number.MAX_VALUE; - constructor(protected name: string, opts?: QueueSchedulerOptions) { - super(name, opts); - - this.opts = Object.assign(this.opts, { - maxStalledCount: 1, - stalledInterval: 30000, - }); + constructor(protected name: string, opts: QueueSchedulerOptions = {}) { + super(name, { maxStalledCount: 1, stalledInterval: 30000, ...opts }); } async init() { @@ -111,16 +106,14 @@ export class QueueScheduler extends QueueBase { const [failed, stalled] = await Scripts.moveStalledJobsToWait(this); - failed.forEach((jobId: string) => { + failed.forEach((jobId: string) => this.emit( 'failed', jobId, new Error('job stalled more than allowable limit'), 'active', - ); - }); - stalled.forEach((jobId: string) => { - this.emit('stalled', jobId); - }); + ), + ); + stalled.forEach((jobId: string) => this.emit('stalled', jobId, 'active')); } }