Skip to content

🐛 this.pubClient.duplicate is not a function #11

@seelrd

Description

@seelrd

Package

@nestjs-redis/socket.io-adapter

Version

0.12.1

What happened?

I added RedisModule in app.module.ts like this:

import { RedisModule } from "@nestjs-redis/kit";

//imports
RedisModule.forRoot({
    isGlobal: true,
    type: 'sentinel',
    options: {
      name: process.env.REDIS_SENTINEL_NAME,
      sentinelRootNodes: process.env.REDIS_SENTINELS
        ? process.env.REDIS_SENTINELS.split(',').map((entry) => {
          const [host, port] = entry.split(':');
          return { host, port: parseInt(port) };
        })
        : []
    }
  }),

In main.ts:

const app = ...;
await setupRedisAdapter(app);

At app launch I get this error:

[UNHANDLED REJECTION] at: Promise {
  <rejected> TypeError: this.pubClient.duplicate is not a function
      at RedisIoAdapter.connectToRedis (/home/prod/likner-backend/node_modules/@nestjs-redis/socket.io-adapter/src/lib/redis-io.adapter.js:9:41)
      at setupRedisAdapter (/home/prod/likner-backend/node_modules/@nestjs-redis/socket.io-adapter/src/lib/setup-redis-adapter.js:28:30)
      at bootstrap (/home/prod/likner-backend/dist/main.js:37:39)
      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
} reason: TypeError: this.pubClient.duplicate is not a function
    at RedisIoAdapter.connectToRedis (/home/prod/likner-backend/node_modules/@nestjs-redis/socket.io-adapter/src/lib/redis-io.adapter.js:9:41)
    at setupRedisAdapter (/home/prod/likner-backend/node_modules/@nestjs-redis/socket.io-adapter/src/lib/setup-redis-adapter.js:28:30)
    at bootstrap (/home/prod/likner-backend/dist/main.js:37:39)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

Steps to reproduce

  1. Install package
  2. Add to app.module.ts config with sentinels
  3. Use redis connection with SocketIO adapter

Code example

Environment

Node.js: v22.20.0
NestJS: 11.1.6
Redis: 8.0.2

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions