From 193644c5ed290901448f8c35ede99e1063a90f4a Mon Sep 17 00:00:00 2001 From: Manuel Astudillo Date: Mon, 14 Feb 2022 19:22:58 +0800 Subject: [PATCH] fix(queue): return correct workers with getWorkers() --- lib/queue.js | 1 - lib/worker.js | 2 +- test/test_worker.js | 9 +++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/queue.js b/lib/queue.js index 73cd8bf0d..b60ec2315 100755 --- a/lib/queue.js +++ b/lib/queue.js @@ -284,7 +284,6 @@ function redisClientGetter(queue, options, initCallback) { return connections[type]; } const clientOptions = _.assign({}, options.redis); - clientOptions.connectionName = this.clientName(); const client = (connections[type] = createClient(type, clientOptions)); diff --git a/lib/worker.js b/lib/worker.js index c7c3b0cb4..a656a406b 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -13,7 +13,7 @@ module.exports = function(Queue) { return utils .isRedisReady(this.client) .then(() => { - return this.client.client('setname', this.clientName()); + return this.bclient.client('setname', this.clientName()); }) .catch(err => { if (!clientCommandMessageReg.test(err.message)) throw err; diff --git a/test/test_worker.js b/test/test_worker.js index ee50c01c1..aa454fd53 100644 --- a/test/test_worker.js +++ b/test/test_worker.js @@ -27,11 +27,12 @@ describe('workers', () => { }); }); - it('should get all workers for this queue', () => { + it('should get all workers for this queue', async () => { queue.process(() => {}); - return queue.getWorkers().then(workers => { - expect(workers).to.have.length(1); - }); + await queue.bclient.ping(); + + const workers = await queue.getWorkers(); + expect(workers).to.have.length(1); }); });