cacheable
cacheable copied to clipboard
The `cacheManager.get()` method with @keyv/redis is freezing or blocking the code if the Redis connection is lost
Describe the bug
When Redis disconnects, the store created via @keyv/redis keeps trying to connect to Redis, and the cacheManager.get() method blocks the code.
How To Reproduce (best to provide workable code or tests!)
import { Module } from '@nestjs/common';
import { CacheModule } from '@nestjs/cache-manager';
import { createKeyv } from '@keyv/redis';
import { Keyv } from 'keyv';
@Module({
imports: [
CacheModule.registerAsync({
useFactory: async () => {
return {
stores: [
createKeyv('redis://localhost:6379'),
],
};
},
}),
],
})
export class AppModule {}
const value = await this.cacheManager.get('key');
Expected behavior After a configurable or defined duration, it should fail with an error/exception
NestJS version 11.0.10
Node.js version 22.16.0
Created issue for nestjs/cache-manager https://github.com/nestjs/cache-manager/issues/797, but as per them, this belongs here