Skip to content

Commit 087615f

Browse files
authored
fix redis#2443 - fix multiple sockets on error in socket initiator (redis#2480)
* fix redis#2443 - fix multiple sockets on error in socket initiator * handle `error` events in test
1 parent b2169dc commit 087615f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

packages/client/lib/client/index.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,9 @@ describe('Client', () => {
647647
});
648648

649649
testUtils.testWithClient('should propagated errors from "isolated" clients', client => {
650+
client.on('error', () => {
651+
// ignore errors
652+
});
650653
return client.executeIsolated(isolated => killClient(isolated, client));
651654
}, GLOBAL.SERVERS.OPEN);
652655

packages/client/lib/client/socket.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ export default class RedisSocket extends EventEmitter {
199199
.off('error', reject)
200200
.once('error', (err: Error) => this.#onSocketError(err))
201201
.once('close', hadError => {
202-
if (!hadError && this.#isOpen && this.#socket === socket) {
202+
if (!hadError && this.#isReady && this.#socket === socket) {
203203
this.#onSocketError(new SocketClosedUnexpectedlyError());
204204
}
205205
})

0 commit comments

Comments
 (0)