1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

fix reconnecting event (#2396)

* fix #2395 - fix reconnecting event

* Update socket.ts
This commit is contained in:
Leibale Eidelman
2023-01-28 18:20:48 -05:00
committed by GitHub
parent 58e572bdc7
commit b3cd78503d

View File

@@ -162,17 +162,15 @@ export default class RedisSocket extends EventEmitter {
this.#isReady = true;
this.emit('ready');
} catch (err) {
const retryIn = this.#shouldReconnect(retries, err as Error);
const retryIn = this.#shouldReconnect(retries++, err as Error);
if (typeof retryIn !== 'number') {
throw retryIn;
}
this.emit('error', err);
await promiseTimeout(retryIn);
this.emit('reconnecting');
}
retries++;
this.emit('reconnecting');
} while (this.#isOpen && !this.#isReady);
}