From b39cc356ff87c168c1058e4784cded7ab09bb393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadeusz=20So=C5=9Bnierz?= <tadzik@tadzik.net> Date: Tue, 9 Aug 2022 13:00:21 +0200 Subject: [PATCH] Log errors from floating Promises (#823) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Log errors from floating Promises Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com> --- changelog.d/823.bugfix | 1 + src/bot.ts | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 changelog.d/823.bugfix diff --git a/changelog.d/823.bugfix b/changelog.d/823.bugfix new file mode 100644 index 0000000..4e4b072 --- /dev/null +++ b/changelog.d/823.bugfix @@ -0,0 +1 @@ +Make sure we don't lose errors thrown when checking usage limits. diff --git a/src/bot.ts b/src/bot.ts index 73c0345..2e34e56 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -218,7 +218,9 @@ export class DiscordBot { if (this.config.bridge.userLimit !== null) { log.info(`Bridge blocker is enabled with a user limit of ${this.config.bridge.userLimit}`); this.bridgeBlocker = new DiscordBridgeBlocker(this.config.bridge.userLimit, this); - this.bridgeBlocker?.checkLimits(activeUsers); + this.bridgeBlocker?.checkLimits(activeUsers).catch(err => { + log.error(`Failed to check bridge limits: ${err}`); + }); } } @@ -1235,7 +1237,9 @@ export class DiscordBot { await this.store.storeUserActivity(userId, state.dataSet.users[userId]); } log.verbose(`Checking bridge limits (${state.activeUsers} active users)`); - this.bridgeBlocker?.checkLimits(state.activeUsers); + this.bridgeBlocker?.checkLimits(state.activeUsers).catch(err => { + log.error(`Failed to check bridge limits: ${err}`); + });; MetricPeg.get.setRemoteMonthlyActiveUsers(state.activeUsers); } } @@ -1278,7 +1282,9 @@ class AdminNotifier { await this.client.inviteUser(mxid, roomId); } catch (err) { log.verbose(`Failed to invite ${mxid} to ${roomId}, cleaning up`); - this.client.leaveRoom(roomId); // no point awaiting it, nothing we can do if we fail + this.client.leaveRoom(roomId).catch(err => { + log.error(`Failed to clean up to-be-DM room ${roomId}: ${err}`); + }); throw err; } -- GitLab