From 2f5f8e476770c7db5b6700ed4a8c0044c4c169e0 Mon Sep 17 00:00:00 2001 From: Siddharth VP Date: Fri, 29 Mar 2024 18:34:50 +0530 Subject: [PATCH] redis: handle errors to prevent crashes --- redis.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/redis.ts b/redis.ts index 8d3266a..9e2c1b6 100644 --- a/redis.ts +++ b/redis.ts @@ -1,6 +1,7 @@ import * as redis from 'redis'; import * as asyncRedis from "async-redis"; import { onToolforge, readFile } from "./utils"; +import { log } from "./botbase"; // Source: https://github.com/moaxaca/async-redis (MIT) // for some reason the Promisified type that we need isn't exported from there @@ -53,6 +54,10 @@ export function getRedisConfig(config: redis.ClientOpts = {}): redis.ClientOpts export function getRedisInstance(): Redis { if (!instance) { instance = createRedisClient(); + instance.on('error', (err: Error) => { + log(`[E] Redis error`); + log(err); + }); } return instance; }