[ ] Regression
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Currently when i'm using CacheModule.register and redis connection fails, the server exits with an error:
Error: Redis connection to redis:6379 failed - getaddrinfo ENOTFOUND redis redis:6379
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)
Handle the error to just log the error and not break the entire app, maybe add a retry exponentially.
Nest version: 5.4.0
For Tooling issues:
- Node version: v10.6.0
- Platform: Mac
Others:
Please, provide a minimal repository which reproduces your issue.
@kamilmysliwiec
https://github.com/yogevlahyani/nestjs-redis-cache-example
Basically, I don't want the process to exit with error, just log that the redis is unable to connect or something
You need to inject the exposed CACHE_MANAGER in the module constructor to get your hands on the redis client:
import { CACHE_MANAGER, Inject } from '@nestjs/common';
...
export class AppModule {
constructor(@Inject(CACHE_MANAGER) cacheManager) {
const client = cacheManager.store.getClient();
client.on('error', (error) => {
console.error(error);
});
}
}
@atte-backman I tried it but inside a service, seems that inside the AppModule it doesn't breaks the app,
Thanks!! :100:
I think we should keep this opened to solve this problem out-of-the-box
@kamilmysliwiec Agreed! 馃
Oh I missed one thing :( It actually should be fixed here https://github.com/dabroek/node-cache-manager-redis-store We don't provide this store out-of-the-box, my mistake!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.