nestjs / cache-manager

Cache manager module for Nest framework (node.js) 🗃
MIT License
111 stars 19 forks source link

App crashing on redis WRONGPASS error and no way recover from this state #429

Closed kumarrsk closed 4 days ago

kumarrsk commented 4 days ago

Is there an existing issue for this?

Current behavior

Currently, we have implemented Redis with Cache Manager in our project. The Redis password is stored in a key vault and is updated monthly. Once the password is updated in the key vault, Redis throws a WRONGPASS error, causing the app to crash. Restarting the server is the only fix we have now.

Is it possible to re-register with the new configuration in app.module.ts, or is there another way to handle this?

The error is as follows WRONGPASS invalid username-password pair "stack":[[{"command":"AUTH","args":["ere22dwdwqq"],"code":"WRONGPASS"}]]}

cache-manager-redis-store : 2.0.0 redis: 4.6.13

code is similar to this @Module({ imports: [ CacheModule.registerAsync({ imports: [ConfigModule], inject: [ConfigService, KeyVaultService], useFactory: async (configService: ConfigService, keyVaultService: KeyVaultService) => ({ store: redisStore, socket: { tls: true, noDelay: true, }, url: host:port/15, password: 'await getPassWord(configService, keyVaultService), }), isGlobal: true, }), ], }) export class AppModule { constructor(@Inject(CACHE_MANAGER) cacheManager) { const client = cacheManager?.store?.getClient(); client.on('error', (error) => { console.error(Redis error, error); }); client.on('connect', () => console.log(Redis is connecting)); client.on('reconnecting', () => console.log(Redis is reconnecting), ); client.on('ready', () => console.log(Redis is ready)); client.on('end', () => console.log(Redis is end));
}}

Minimum reproduction code

nil

Steps to reproduce

nil

Expected behavior

reconnect redis with updated password

Package version

2.2.2

NestJS version

10.3.2

Node.js version

v16.20.2

In which operating systems have you tested?

Other

No response

kamilmysliwiec commented 4 days ago

Thank you for taking the time to submit your report! From the looks of it, this could be better discussed on our Discord. If you haven't already, please join here and send a new post in the #⁠ 🐈 nestjs-help forum. Make sure to include a link to this issue, so you don't need to write it all again. We have a large community of helpful members, who will assist you in getting this to work.