You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
fix client.reset
This commit is contained in:
@@ -299,6 +299,11 @@ export default class RedisCommandsQueue {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetDecoder() {
|
||||||
|
this.#resetDecoderCallbacks();
|
||||||
|
this.decoder.reset();
|
||||||
|
}
|
||||||
|
|
||||||
#resetFallbackOnReply?: Decoder['onReply'];
|
#resetFallbackOnReply?: Decoder['onReply'];
|
||||||
|
|
||||||
async reset<T extends TypeMapping>(typeMapping?: T) {
|
async reset<T extends TypeMapping>(typeMapping?: T) {
|
||||||
@@ -384,7 +389,7 @@ export default class RedisCommandsQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
flushWaitingForReply(err: Error): void {
|
flushWaitingForReply(err: Error): void {
|
||||||
this.decoder.reset();
|
this.resetDecoder();
|
||||||
this.#pubSub.reset();
|
this.#pubSub.reset();
|
||||||
|
|
||||||
this.#flushWaitingForReply(err);
|
this.#flushWaitingForReply(err);
|
||||||
@@ -402,7 +407,7 @@ export default class RedisCommandsQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
flushAll(err: Error): void {
|
flushAll(err: Error): void {
|
||||||
this.decoder.reset();
|
this.resetDecoder();
|
||||||
this.#pubSub.reset();
|
this.#pubSub.reset();
|
||||||
this.#flushWaitingForReply(err);
|
this.#flushWaitingForReply(err);
|
||||||
for (const node of this.#toWrite) {
|
for (const node of this.#toWrite) {
|
||||||
|
@@ -429,7 +429,7 @@ export default class RedisClient<
|
|||||||
try {
|
try {
|
||||||
this.#queue.decoder.write(chunk);
|
this.#queue.decoder.write(chunk);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.#queue.decoder.reset();
|
this.#queue.resetDecoder();
|
||||||
this.emit('error', err);
|
this.emit('error', err);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -899,6 +899,7 @@ export default class RedisClient<
|
|||||||
async reset() {
|
async reset() {
|
||||||
const promises = [this._self.#queue.reset()];
|
const promises = [this._self.#queue.reset()];
|
||||||
this._self.#handshake(false, promises);
|
this._self.#handshake(false, promises);
|
||||||
|
this._self.#scheduleWrite();
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user