Skip to content

Commit baef348

Browse files
committed
fix client.reset
1 parent 1006e3b commit baef348

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

packages/client/lib/client/commands-queue.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,11 @@ export default class RedisCommandsQueue {
299299
});
300300
}
301301

302+
resetDecoder() {
303+
this.#resetDecoderCallbacks();
304+
this.decoder.reset();
305+
}
306+
302307
#resetFallbackOnReply?: Decoder['onReply'];
303308

304309
async reset<T extends TypeMapping>(typeMapping?: T) {
@@ -384,7 +389,7 @@ export default class RedisCommandsQueue {
384389
}
385390

386391
flushWaitingForReply(err: Error): void {
387-
this.decoder.reset();
392+
this.resetDecoder();
388393
this.#pubSub.reset();
389394

390395
this.#flushWaitingForReply(err);
@@ -402,7 +407,7 @@ export default class RedisCommandsQueue {
402407
}
403408

404409
flushAll(err: Error): void {
405-
this.decoder.reset();
410+
this.resetDecoder();
406411
this.#pubSub.reset();
407412
this.#flushWaitingForReply(err);
408413
for (const node of this.#toWrite) {

packages/client/lib/client/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ export default class RedisClient<
429429
try {
430430
this.#queue.decoder.write(chunk);
431431
} catch (err) {
432-
this.#queue.decoder.reset();
432+
this.#queue.resetDecoder();
433433
this.emit('error', err);
434434
}
435435
})
@@ -899,6 +899,7 @@ export default class RedisClient<
899899
async reset() {
900900
const promises = [this._self.#queue.reset()];
901901
this._self.#handshake(false, promises);
902+
this._self.#scheduleWrite();
902903
await Promise.all(promises);
903904
}
904905

0 commit comments

Comments
 (0)