From b522a57c1dc0622785176bc032facc729a2cdd8c Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Fri, 7 Jun 2024 13:39:45 +0000 Subject: [PATCH] fix: catch errors --- .../src/modules/jobs/redis/jobs-redis.ts | 24 ++++++++++++------- packages/nocodb/src/redis/pubsub-redis.ts | 2 +- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/packages/nocodb/src/modules/jobs/redis/jobs-redis.ts b/packages/nocodb/src/modules/jobs/redis/jobs-redis.ts index c8128eeeb0..eab4f19b2b 100644 --- a/packages/nocodb/src/modules/jobs/redis/jobs-redis.ts +++ b/packages/nocodb/src/modules/jobs/redis/jobs-redis.ts @@ -21,14 +21,22 @@ export class JobsRedis extends PubSubRedis { await this.init(); } const onMessage = async (channel, message) => { - const args = message.split(':'); - const command = args.shift(); - if (channel === InstanceTypes.WORKER) { - this.workerCallbacks[command] && - (await this.workerCallbacks[command](...args)); - } else if (channel === InstanceTypes.PRIMARY) { - this.primaryCallbacks[command] && - (await this.primaryCallbacks[command](...args)); + try { + if (!message || !message.includes(':')) { + return; + } + const args = message.split(':'); + const command = args.shift(); + + if (channel === InstanceTypes.WORKER) { + this.workerCallbacks[command] && + (await this.workerCallbacks[command](...args)); + } else if (channel === InstanceTypes.PRIMARY) { + this.primaryCallbacks[command] && + (await this.primaryCallbacks[command](...args)); + } + } catch (error) { + this.logger.error('Error processing message' + error); } }; if (process.env.NC_WORKER_CONTAINER === 'true') { diff --git a/packages/nocodb/src/redis/pubsub-redis.ts b/packages/nocodb/src/redis/pubsub-redis.ts index 1b639c3f4c..2626ac252e 100644 --- a/packages/nocodb/src/redis/pubsub-redis.ts +++ b/packages/nocodb/src/redis/pubsub-redis.ts @@ -34,7 +34,7 @@ export class PubSubRedis { await callback(...args); } } catch (error) { - PubSubRedis.logger.error('Error processing message', error); + PubSubRedis.logger.error('Error processing message' + error); } });