Closed
Description
I had a chance to try the new shard PubSub adapter. Mostly works good, but when enable cleanupEmptyChildNamespaces
, the close
function will throw "CROSSSLOT Keys in request don't hash to the same slot". The root cause is redis/node-redis#2502
Currently,
close() {
const channels = [this.channel, this.responseChannel];
if (this.opts.subscriptionMode === "dynamic") {
this.rooms.forEach((_sids, room) => {
const isPublicRoom = !this.sids.has(room);
if (isPublicRoom) {
channels.push(this.dynamicChannel(room));
}
});
}
// channels has at least 2 different strings, `sUnsubscribe` assumes
// they would be hashed to the same slot which is not correct.
return this.subClient.sUnsubscribe(channels);
}
A potential workaround
return Promise.all(channels.map((channel) => this.subClient.sUnsubscribe(channel)));
// return this.subClient.sUnsubscribe(channels);