From 03b3bb5b30a80e4970ebffee92225e71c7f6990e Mon Sep 17 00:00:00 2001 From: LouisLam Date: Thu, 22 Jul 2021 12:28:47 +0800 Subject: [PATCH] fix if notification throw exception, the heartbeat is not stored in to the db. --- server/model/monitor.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index f81f6e00e..04feea6b0 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -121,8 +121,6 @@ class Monitor extends BeanModel { this.id ]) - let promiseList = []; - let text; if (bean.status === 1) { text = "✅ Up" @@ -133,10 +131,12 @@ class Monitor extends BeanModel { let msg = `[${this.name}] [${text}] ${bean.msg}`; for(let notification of notificationList) { - promiseList.push(Notification.send(JSON.parse(notification.config), msg, await this.toJSON(), bean.toJSON())); + try { + await Notification.send(JSON.parse(notification.config), msg, await this.toJSON(), bean.toJSON()) + } catch (e) { + console.error("Cannot send notification to " + notification.name) + } } - - await Promise.all(promiseList); } } else {