diff --git a/lib/queue.js b/lib/queue.js index 1c5ac9ab8..9e2e46ffe 100755 --- a/lib/queue.js +++ b/lib/queue.js @@ -570,7 +570,11 @@ async function redisClientDisconnect(client) { } Queue.prototype.disconnect = async function() { - await Promise.all(this.clients.map(redisClientDisconnect)); + await Promise.all( + this.clients.map(client => + client.blocked ? client.disconnect() : redisClientDisconnect(client) + ) + ); }; Queue.prototype.removeJobs = function(pattern) { @@ -1190,11 +1194,13 @@ Queue.prototype.getNextJob = async function() { // Waiting for new jobs to arrive // try { + this.bclient.blocked = true; const jobId = await this.bclient.brpoplpush( this.keys.wait, this.keys.active, this.settings.drainDelay ); + this.bclient.blocked = false; if (jobId) { return this.moveToActive(jobId);