From 8142d8cff98dbe44135091c919001585292d9469 Mon Sep 17 00:00:00 2001 From: Rory& Date: Tue, 16 Dec 2025 05:15:50 +0100 Subject: [PATCH] Try/catch in GetSafeChannel to maybe catch createchannel errors???? --- src/util/util/RabbitMQ.ts | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/util/util/RabbitMQ.ts b/src/util/util/RabbitMQ.ts index f11f701fb..2f45c26d5 100644 --- a/src/util/util/RabbitMQ.ts +++ b/src/util/util/RabbitMQ.ts @@ -54,19 +54,24 @@ export const RabbitMQ: { if (this.channel) return this.channel; - this.channel = await this.connection.createChannel(); - console.log(`[RabbitMQ] channel created`); + try { + this.channel = await this.connection.createChannel(); + console.log(`[RabbitMQ] channel created`); - // log channel errors - this.channel.on("error", (err) => { - console.error("[RabbitMQ] Channel Error:", err); - }); + // log channel errors + this.channel.on("error", (err) => { + console.error("[RabbitMQ] Channel Error:", err); + }); - this.channel.on("close", () => { - console.log("[RabbitMQ] channel closed"); - this.channel = null; - }); + this.channel.on("close", () => { + console.log("[RabbitMQ] channel closed"); + this.channel = null; + }); - return this.channel; + return this.channel; + } catch (e) { + console.error("[RabbitMQ] Failed to create channel:", e); + return Promise.reject(e); + } }, };