Skip to content
This repository was archived by the owner on Mar 9, 2023. It is now read-only.

Commit 36b4904

Browse files
authored
fix(queue): remove error event listener on close (bee-queue#231)
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 a8c9d87 commit 36b4904

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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)