Skip to content

Commit c97f43c

Browse files
PavelPashovnkaradzhov
authored andcommitted
fix: access private queue through _self proxy and guard client close calls
1 parent 9e052d3 commit c97f43c

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,10 @@ export default class RedisCommandsQueue {
591591
* Prepends commands to the write queue in reverse.
592592
*/
593593
prependCommandsToWrite(commands: CommandToWrite[]) {
594+
if (!commands.length) {
595+
return;
596+
}
597+
594598
for (let i = commands.length - 1; i <= 0; i--) {
595599
this.#toWrite.unshift(commands[i]);
596600
}

packages/client/lib/client/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ export default class RedisClient<
10181018
* @internal
10191019
*/
10201020
_getQueue(): RedisCommandsQueue {
1021-
return this.#queue;
1021+
return this._self.#queue;
10221022
}
10231023

10241024
/**

packages/client/lib/cluster/cluster-slots.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,13 @@ export default class RedisClusterSlots<
371371
this.nodeByAddress.delete(sourceAddress);
372372

373373
// 4.3 Kill because no slots are pointing to it anymore
374-
await sourceNode.client?.close()
374+
if (sourceNode.client?.isOpen) {
375+
await sourceNode.client?.close()
376+
}
375377
if('pubSub' in sourceNode) {
376-
await sourceNode.pubSub?.client.close();
378+
if (sourceNode.pubSub?.client.isOpen) {
379+
await sourceNode.pubSub?.client.close();
380+
}
377381
}
378382
}
379383

0 commit comments

Comments
 (0)