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

fix client.reset

This commit is contained in:
Leibale
2024-01-31 13:23:26 -05:00
parent 1006e3b29f
commit baef3486ad
2 changed files with 9 additions and 3 deletions

View File

@@ -299,6 +299,11 @@ export default class RedisCommandsQueue {
});
}
resetDecoder() {
this.#resetDecoderCallbacks();
this.decoder.reset();
}
#resetFallbackOnReply?: Decoder['onReply'];
async reset<T extends TypeMapping>(typeMapping?: T) {
@@ -384,7 +389,7 @@ export default class RedisCommandsQueue {
}
flushWaitingForReply(err: Error): void {
this.decoder.reset();
this.resetDecoder();
this.#pubSub.reset();
this.#flushWaitingForReply(err);
@@ -402,7 +407,7 @@ export default class RedisCommandsQueue {
}
flushAll(err: Error): void {
this.decoder.reset();
this.resetDecoder();
this.#pubSub.reset();
this.#flushWaitingForReply(err);
for (const node of this.#toWrite) {

View File

@@ -429,7 +429,7 @@ export default class RedisClient<
try {
this.#queue.decoder.write(chunk);
} catch (err) {
this.#queue.decoder.reset();
this.#queue.resetDecoder();
this.emit('error', err);
}
})
@@ -899,6 +899,7 @@ export default class RedisClient<
async reset() {
const promises = [this._self.#queue.reset()];
this._self.#handshake(false, promises);
this._self.#scheduleWrite();
await Promise.all(promises);
}