Skip to content

🐛 Unexpected behavior when using RedisHealthIndicator #6

@Baylem

Description

@Baylem

Package

@nestjs-redis/kit

Version

0.10.1

What happened?

I'll start this off by saying I am new to NestJS and may just be doing something simple wrong.

I am trying to use @nestjs-redis/kit v0.10.1 to streamline my redis usage in my NestJS project. I'm starting off by trying to add it to my healthz endpoint.

With this, when I try to hit me /healthz endpoint I get this error:

[Nest] 63732  - 08/17/2025, 12:05:46 AM     LOG [NestFactory] Starting Nest application...
[Nest] 63732  - 08/17/2025, 12:05:46 AM     LOG [NestApplication] Nest application successfully started +16ms
[Nest] 63732  - 08/17/2025, 12:07:13 AM   ERROR [ExceptionsHandler] TypeError: Cannot read properties of undefined (reading 'check')
    at _classThis.isHealthy (D:\Storage\Development\Projects\TLT\tlt\node_modules\@nestjs-redis\health-indicator\src\lib\health.indicator.js:16:59)
    at D:\Storage\Development\Projects\TLT\tlt\packages\api\dist\health\health.controller.js:35:30
    at HealthCheckExecutor.<anonymous> (D:\Storage\Development\Projects\TLT\tlt\node_modules\@nestjs\terminus\lib\health-check\health-check-executor.service.ts:63:41)
    at Generator.next (<anonymous>)
    at D:\Storage\Development\Projects\TLT\tlt\node_modules\@nestjs\terminus\dist\health-check\health-check-executor.service.js:14:71
    at new Promise (<anonymous>)
    at __awaiter (D:\Storage\Development\MarcusK\Projects\TLT\tlt\node_modules\@nestjs\terminus\dist\health-check\health-check-executor.service.js:10:12)
    at <anonymous> (D:\Storage\Development\Projects\TLT\tlt\node_modules\@nestjs\terminus\lib\health-check\health-check-executor.service.ts:63:40)
    at Array.map (<anonymous>)
    at HealthCheckExecutor.<anonymous> (D:\Storage\Development\Projects\TLT\tlt\node_modules\@nestjs\terminus\lib\health-check\health-check-executor.service.ts:63:24)

Steps to reproduce

  1. Install Redis,. NestJS and NestJS-Redis
  2. Set up the NestJS Redis according to the health indicator documentation
  3. Hit the endpoint
  4. see the error

Code example

app.module.ts

@Module({
  imports: [HealthModule],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

app.controller.ts

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get()
  getHello(): string {
    return this.appService.getHello();
  }
}

health.module.ts

@Module({
  imports: [
    RedisModule.forRoot({
      type: 'client',
      options: { url: process.env.REDIS_URL },
    }),
    TerminusModule,
  ],
  controllers: [HealthController],
  providers: [RedisHealthIndicator],
})
export class HealthModule {}

health.controller.ts

@Controller('healthz')
export class HealthController {
  constructor(
    private health: HealthCheckService,
    private redis: RedisHealthIndicator,
    @InjectRedis() private readonly redisClient: Redis,
  ) {}

  @Get()
  @HealthCheck()
  check(): Promise<HealthCheckResult> {
    return this.health.check([
      () => this.redis.isHealthy('redis', { client: this.redisClient })
    ]);
  }
}

Environment

Node.js: 22.18.0
NestJS: 11.1.6
Redis: 5.8.1

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