Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dc03d68

Browse files
author
Eli Skeggs
committed
fix(queue): remove error event listener on close
The error event listener is useful for catching errors from redis clients that aren't managed by the consumer of the library, but might cause problems for re-used connections.
1 parent 52736f5 commit dc03d68

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

lib/queue.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ class Queue extends Emitter {
7575
return redis
7676
.createClient(this.settings.redis, createNew)
7777
.then((client) => {
78+
// This event gets cleaned up and removed in Queue#close for the
79+
// primary client if quitCommandClient is disabled.
7880
client.on('error', this._emitError);
7981
return (this[clientName] = client);
8082
});
@@ -222,8 +224,12 @@ class Queue extends Emitter {
222224
this._isClosed = true;
223225

224226
const clients = [];
225-
if (this.settings.quitCommandClient && this.client) {
226-
clients.push(this.client);
227+
if (this.client) {
228+
if (this.settings.quitCommandClient) {
229+
clients.push(this.client);
230+
} else {
231+
this.client.removeListener('error', this._emitError);
232+
}
227233
}
228234
if (this.eclient) {
229235
clients.push(this.eclient);

0 commit comments

Comments
 (0)