diff --git a/packages/client/lib/client/socket.ts b/packages/client/lib/client/socket.ts index 4c64f899559..7a5adabdf74 100644 --- a/packages/client/lib/client/socket.ts +++ b/packages/client/lib/client/socket.ts @@ -162,17 +162,16 @@ 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); }