From a68fbcc520910089db0b64215472b1df4ffd8503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Skyler=20M=C3=A4ntysaari?= Date: Sun, 9 Apr 2023 04:35:08 +0300 Subject: [PATCH] chore(server): redis error handling (#2212) * chore(server): bull error handler * chore(server): redis error handling * Let's not touch bull --- server/libs/infra/src/redis-io.adapter.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/libs/infra/src/redis-io.adapter.ts b/server/libs/infra/src/redis-io.adapter.ts index 9637d812a6..ac03408d9f 100644 --- a/server/libs/infra/src/redis-io.adapter.ts +++ b/server/libs/infra/src/redis-io.adapter.ts @@ -1,13 +1,21 @@ import { IoAdapter } from '@nestjs/platform-socket.io'; import { createAdapter } from '@socket.io/redis-adapter'; import Redis from 'ioredis'; +import { Logger } from '@nestjs/common'; import { ServerOptions } from 'socket.io'; import { redisConfig } from './infra.config'; export class RedisIoAdapter extends IoAdapter { + private readonly logger = new Logger(RedisIoAdapter.name); createIOServer(port: number, options?: ServerOptions): any { const pubClient = new Redis(redisConfig); + pubClient.on('error', (error) => { + this.logger.error(`Redis pubClient: ${error}`); + }); const subClient = pubClient.duplicate(); + subClient.on('error', (error) => { + this.logger.error(`Redis subClient: ${error}`); + }); const server = super.createIOServer(port, options); server.adapter(createAdapter(pubClient, subClient)); return server;