ioredis 5.9.1 → 5.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -112,12 +112,17 @@ class ClusterSubscriberGroup {
|
|
|
112
112
|
return Array.from(this.channels.values()).reduce((sum, array) => sum + array.length, 0);
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
115
|
-
* Disconnect all subscribers
|
|
115
|
+
* Disconnect all subscribers and clear some of the internal state.
|
|
116
116
|
*/
|
|
117
117
|
stop() {
|
|
118
118
|
for (const s of this.shardedSubscribers.values()) {
|
|
119
119
|
s.stop();
|
|
120
120
|
}
|
|
121
|
+
// Clear subscriber instances and pending operations.
|
|
122
|
+
// Channels are preserved for resubscription on reconnect.
|
|
123
|
+
this.pendingReset = null;
|
|
124
|
+
this.shardedSubscribers.clear();
|
|
125
|
+
this.subscriberToSlotsIndex.clear();
|
|
121
126
|
}
|
|
122
127
|
/**
|
|
123
128
|
* Start all not yet started subscribers
|
package/built/cluster/index.js
CHANGED
|
@@ -890,18 +890,28 @@ class Cluster extends Commander_1.default {
|
|
|
890
890
|
createShardedSubscriberGroup() {
|
|
891
891
|
this.subscriberGroupEmitter = new events_1.EventEmitter();
|
|
892
892
|
this.shardedSubscribers = new ClusterSubscriberGroup_1.default(this.subscriberGroupEmitter);
|
|
893
|
+
// Error handler used only for sharded-subscriber-triggered slots cache refreshes.
|
|
894
|
+
// Normal (non-subscriber) connections are created with lazyConnect: true and can
|
|
895
|
+
// become zombied. For sharded subscribers, a ClusterAllFailedError means
|
|
896
|
+
// we have lost all nodes from the subscriber perspective and must tear down.
|
|
897
|
+
const refreshSlotsCacheCallback = (err) => {
|
|
898
|
+
// Disconnect only when refreshing the slots cache fails with ClusterAllFailedError
|
|
899
|
+
if (err instanceof ClusterAllFailedError_1.default) {
|
|
900
|
+
this.disconnect(true);
|
|
901
|
+
}
|
|
902
|
+
};
|
|
893
903
|
this.subscriberGroupEmitter.on("-node", (redis, nodeKey) => {
|
|
894
904
|
this.emit("-node", redis, nodeKey);
|
|
895
|
-
this.refreshSlotsCache();
|
|
905
|
+
this.refreshSlotsCache(refreshSlotsCacheCallback);
|
|
896
906
|
});
|
|
897
907
|
this.subscriberGroupEmitter.on("subscriberConnectFailed", ({ delay, error }) => {
|
|
898
908
|
this.emit("error", error);
|
|
899
909
|
setTimeout(() => {
|
|
900
|
-
this.refreshSlotsCache();
|
|
910
|
+
this.refreshSlotsCache(refreshSlotsCacheCallback);
|
|
901
911
|
}, delay);
|
|
902
912
|
});
|
|
903
913
|
this.subscriberGroupEmitter.on("moved", () => {
|
|
904
|
-
this.refreshSlotsCache();
|
|
914
|
+
this.refreshSlotsCache(refreshSlotsCacheCallback);
|
|
905
915
|
});
|
|
906
916
|
this.subscriberGroupEmitter.on("-subscriber", () => {
|
|
907
917
|
this.emit("-subscriber");
|