Skip to content

Commit 146f69b

Browse files
authored
fix reconnecting event (redis#2396)
* fix redis#2395 - fix reconnecting event * Update socket.ts
1 parent b60a41d commit 146f69b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

packages/client/lib/client/socket.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,15 @@ export default class RedisSocket extends EventEmitter {
162162
this.#isReady = true;
163163
this.emit('ready');
164164
} catch (err) {
165-
const retryIn = this.#shouldReconnect(retries, err as Error);
165+
const retryIn = this.#shouldReconnect(retries++, err as Error);
166166
if (typeof retryIn !== 'number') {
167167
throw retryIn;
168168
}
169169

170170
this.emit('error', err);
171171
await promiseTimeout(retryIn);
172+
this.emit('reconnecting');
172173
}
173-
174-
retries++;
175-
this.emit('reconnecting');
176174
} while (this.#isOpen && !this.#isReady);
177175
}
178176

0 commit comments

Comments
 (0)