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

fix(clustered pubsub): check that client.isOpen before calling client.disconnect() when unsubscribing (#2687)

* Confirm the client isOpen before disconnecting

* Write tests

* fix tests

* fix tests

---------

Co-authored-by: Leibale Eidelman <me@leibale.com>
This commit is contained in:
Brent Layne
2024-01-29 03:25:26 -05:00
committed by GitHub
parent 5a96058c2f
commit 295647cf9d
2 changed files with 29 additions and 2 deletions

View File

@@ -562,7 +562,7 @@ export default class RedisClusterSlots<
const client = await this.getPubSubClient();
await unsubscribe(client);
if (!client.isPubSubActive) {
if (!client.isPubSubActive && client.isOpen) {
await client.disconnect();
this.pubSubNode = undefined;
}
@@ -613,7 +613,7 @@ export default class RedisClusterSlots<
const client = await master.pubSubClient;
await unsubscribe(client);
if (!client.isPubSubActive) {
if (!client.isPubSubActive && client.isOpen) {
await client.disconnect();
master.pubSubClient = undefined;
}