diff --git a/lib/queue.js b/lib/queue.js index 39e4e3ff..b899629e 100644 --- a/lib/queue.js +++ b/lib/queue.js @@ -75,6 +75,8 @@ class Queue extends Emitter { return redis .createClient(this.settings.redis, createNew) .then((client) => { + // This event gets cleaned up and removed in Queue#close for the + // primary client if quitCommandClient is disabled. client.on('error', this._emitError); return (this[clientName] = client); }); @@ -222,8 +224,12 @@ class Queue extends Emitter { this._isClosed = true; const clients = []; - if (this.settings.quitCommandClient && this.client) { - clients.push(this.client); + if (this.client) { + if (this.settings.quitCommandClient) { + clients.push(this.client); + } else { + this.client.removeListener('error', this._emitError); + } } if (this.eclient) { clients.push(this.eclient);