From 99ef8728ad31aab78b974156b486c680514496ef Mon Sep 17 00:00:00 2001 From: Siddharth VP Date: Thu, 13 Jun 2024 22:58:24 +0530 Subject: [PATCH] redis: try reconnecting on NR_CLOSED error --- redis.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/redis.ts b/redis.ts index 9e2c1b6..45c256f 100644 --- a/redis.ts +++ b/redis.ts @@ -57,6 +57,10 @@ export function getRedisInstance(): Redis { instance.on('error', (err: Error) => { log(`[E] Redis error`); log(err); + if (err.code === 'NR_CLOSED') { + // XXX: reconnect for next time + instance = createRedisClient(); + } }); } return instance;