Skip to content

In shard mode, close throw error "CROSSSLOT Keys in request don't hash to the same slot" #500

Closed
@ngot

Description

@ngot

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions