Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot destructure property 'master' of 'this.slots[calculateSlot(...)]' as it is undefined #546

Open
noor-siddique-paypay opened this issue Aug 26, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@noor-siddique-paypay
Copy link

I'm encountering an unexpected error when utilizing the socket.io/redis-adapter in my application. Below are the error logs for your reference:

Environment:

Node.js Version: v20.9.0
Redis Instance Version: AWS ElastiCache 7.0.7

Dependencies:

"redis": "4.7.0"
"@socket.io/redis-adapter": "^8.3.0"
"socket.io": "4.7.5"

Code sample:

const pubClient = RedisClient.createCluster({
        rootNodes: [
          {
            socket: {
              host: ".....cache.amazonaws.com",
              port: "6379"
            }
          },
        ],
        defaults: {
          username: "username",
          password: "password",
          socket: {
            tls: true,
            rejectUnauthorized: false
          }
        }
      });

const subClient = pubClient.duplicate();

(async () => {
  await Promise.all([
    pubClient.connect(),
    subClient.connect()
  ]);
})();

io.adapter(createShardedAdapter(pubClient, subClient)); // failing at this stage

Error Log:

/app/node_modules/@redis/client/dist/lib/cluster/cluster-slots.js:144
        const { master } = this.slots[calculateSlot(channel)];
                ^

TypeError: Cannot destructure property 'master' of 'this.slots[calculateSlot(...)]' as it is undefined.
    at RedisClusterSlots.getShardedPubSubClient (/app/node_modules/@redis/client/dist/lib/cluster/cluster-slots.js:144:17)
    at Commander.SSUBSCRIBE (/app/node_modules/@redis/client/dist/lib/cluster/index.js:166:83)
    at SSUBSCRIBE (/app/node_modules/@socket.io/redis-adapter/dist/util.js:54:21)
    at new ShardedRedisAdapter (/app/node_modules/@socket.io/redis-adapter/dist/sharded-adapter.js:39:31)
    at new <anonymous> (/app/node_modules/@socket.io/redis-adapter/dist/sharded-adapter.js:23:16)
    at Namespace._initAdapter (/app/node_modules/socket.io/dist/namespace.js:93:24)
    at Server.adapter (/app/node_modules/socket.io/dist/index.js:188:17)
    at Object.startIo (/app/socket.io/index.js:224:6)
    at Object.<anonymous> (/app/bin/www:57:27)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47
@darrachequesne
Copy link
Member

Hi!

This looks like a bug in the underlying redis package. Could you please open an issue in their repository with all necessary details?

@darrachequesne darrachequesne added the bug Something isn't working label Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants
@darrachequesne @noor-siddique-paypay and others