fastify-redis: how to handle connection error
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the issue has not already been raised
Issue
what is the most correct way to handle redis connection errors, to have a simple human error log?
...
const fastify = Fastify({logger});
fastify.ready(err => {
if (err) {
fastify.log.debug(`Redis Connection Error ${err.code}`)
}
})
fastify.register(require('@fastify/redis'), {
host: config.redis.hosts,
password: config.redis.password
});
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 16 (6 by maintainers)
@stefanocudini - I’m having the same issue. Did you figure this one out yet? If you need help, I’m happy to pair up and do a PR on this one.
@agjs a partial solution for my case is it:
@Eomm thank you very much for your suggestion. I think solved this way with the latest version of the plugin and using some additional parameters
You might need to add some additional logging in https://github.com/fastify/fastify-redis/blob/master/index.js#L61-L99.
Currently, this plugin assumes it can connect to the Redis instance. There is no way to “try again” if the connection fails or the time it tasks is over the time allotted.