Skip to content

Commit 37e9db5

Browse files
authored
perf(worker): call moveToActive after special errors (#3497)
1 parent bd5a8c0 commit 37e9db5

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

src/classes/worker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,8 @@ will never work with more accuracy than 1ms. */
10231023
err instanceof WaitingChildrenError ||
10241024
err.name == 'WaitingChildrenError'
10251025
) {
1026-
return;
1026+
const client = await this.client;
1027+
return this.moveToActive(client, token, this.opts.name);
10271028
}
10281029

10291030
const result = await job.moveToFailed(

tests/test_flow.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('flows', () => {
2222
let queue: Queue;
2323
let queueName: string;
2424

25-
let connection;
25+
let connection: IORedis;
2626
before(async function () {
2727
connection = new IORedis(redisHost, { maxRetriesPerRequest: null });
2828
});
@@ -268,8 +268,9 @@ describe('flows', () => {
268268
async job => {
269269
await delay(100);
270270

271-
const jobIdFromDebounceKey =
272-
await queue.getDebounceJobId('debounce_id');
271+
const jobIdFromDebounceKey = await queue.getDebounceJobId(
272+
'debounce_id',
273+
);
273274
expect(jobIdFromDebounceKey).to.be.equal(job.id);
274275

275276
await flow.add({
@@ -335,8 +336,9 @@ describe('flows', () => {
335336

336337
await completing;
337338

338-
const jobIdFromDebounceKey =
339-
await queue.getDebounceJobId('debounce_id');
339+
const jobIdFromDebounceKey = await queue.getDebounceJobId(
340+
'debounce_id',
341+
);
340342
expect(jobIdFromDebounceKey).to.be.null;
341343

342344
expect(debouncedCounter).to.be.equal(1);
@@ -3427,7 +3429,9 @@ describe('flows', () => {
34273429
} else {
34283430
reject(
34293431
new Error(
3430-
`wrong job (${jobId}) failed instead of ${tree!.children![0].job.id}`,
3432+
`wrong job (${jobId}) failed instead of ${
3433+
tree!.children![0].job.id
3434+
}`,
34313435
),
34323436
);
34333437
}
@@ -3573,7 +3577,9 @@ describe('flows', () => {
35733577
} else {
35743578
reject(
35753579
new Error(
3576-
`wrong job (${jobId}) failed instead of ${tree!.children![0].job.id}`,
3580+
`wrong job (${jobId}) failed instead of ${
3581+
tree!.children![0].job.id
3582+
}`,
35773583
),
35783584
);
35793585
}

tests/test_worker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ describe('workers', function () {
355355
expect(job).to.be.ok;
356356
expect(data).to.be.eql(37);
357357

358-
const gotJob = await queue.getJob(job.id);
359-
expect(gotJob.returnvalue).to.be.eql(37);
358+
const gotJob = await queue.getJob(job.id!);
359+
expect(gotJob!.returnvalue).to.be.eql(37);
360360
resolve();
361361
} catch (err) {
362362
reject(err);

0 commit comments

Comments
 (0)