You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
@@ -199,7 +199,7 @@ export default class RedisSocket extends EventEmitter {
|
||||
.off('error', reject)
|
||||
.once('error', (err: Error) => this.#onSocketError(err))
|
||||
.once('close', hadError => {
|
||||
if (!hadError && this.#isReady && this.#socket === socket) {
|
||||
if (!hadError && this.#isOpen && this.#socket === socket) {
|
||||
this.#onSocketError(new SocketClosedUnexpectedlyError());
|
||||
}
|
||||
})
|
||||
@@ -229,10 +229,11 @@ export default class RedisSocket extends EventEmitter {
|
||||
}
|
||||
|
||||
#onSocketError(err: Error): void {
|
||||
const wasReady = this.#isReady;
|
||||
this.#isReady = false;
|
||||
this.emit('error', err);
|
||||
|
||||
if (!this.#isOpen || typeof this.#shouldReconnect(0, err) !== 'number') return;
|
||||
if (!wasReady || !this.#isOpen || typeof this.#shouldReconnect(0, err) !== 'number') return;
|
||||
|
||||
this.emit('reconnecting');
|
||||
this.#connect().catch(() => {
|
||||
|
Reference in New Issue
Block a user