Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions lib/cluster/ClusterSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,28 @@ export default class ClusterSubscriber {
let pending = 0;
for (const type of ["subscribe", "psubscribe", "ssubscribe"]) {
const channels = previousChannels[type];
if (channels.length) {
if (channels.length == 0) {
continue;
}

debug("%s %d channels", type, channels.length);

if (type === "ssubscribe") {
for (const channel of channels) {
pending += 1;
this.subscriber[type](channel)
.then(() => {
if (!--pending) {
this.lastActiveSubscriber = this.subscriber;
}
})
.catch(() => {
// TODO: should probably disconnect the subscriber and try again.
debug("failed to ssubscribe to channel: %s", channel);
});
}
} else {
pending += 1;
debug("%s %d channels", type, channels.length);
this.subscriber[type](channels)
.then(() => {
if (!--pending) {
Expand Down
Loading