cache-manager
cache-manager copied to clipboard
NestJS microservice gives unclear error when trying to start without Redis running
trafficstars
Describe the bug
Today we upgraded from Node 18 to Node 20, and it seems the error message that pops up when starting a NestJS microservice that depends on a Redis store via cache-manager-redis-yet, if the Redis container is not running, has gotten a lot less clear.
Using Node 18:
Using Node 20:
The Node 18 version of the error isn't great either, but at least the mentioned port 6379 immediately pointed to Redis being the issue.
How To Reproduce
- In a NestJS/NX project, generate a new microservice
- Use as app.module.ts:
import { Global, Module } from '@nestjs/common'
import { AppService } from './app.service'
import { CacheModule } from '@nestjs/cache-manager'
import { RedisClientOptions } from 'redis'
import { redisStore } from 'cache-manager-redis-yet'
@Global()
@Module({
imports: [
CacheModule.register<RedisClientOptions>({
store: redisStore,
url: 'redis://localhost:6379',
isGlobal: true,
}),
],
providers: [AppService],
exports: [AppService],
})
export class AppModule {}
- Make sure there is NO Redis container running at port 6379
- Run the microservice with
nx serve my-micrsoservice.