Skip to content

Commit b3cd785

Browse files
authored
fix reconnecting event (#2396)
* fix #2395 - fix reconnecting event * Update socket.ts
1 parent 58e572b commit b3cd785

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

packages/client/lib/client/socket.ts

+2-4
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)