Skip to content

Commit

Permalink
fix if notification throw exception, the heartbeat is not stored in t…
Browse files Browse the repository at this point in the history
…o the db.
  • Loading branch information
louislam committed Jul 22, 2021
1 parent 7e4a1ad commit 03b3bb5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions server/model/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ class Monitor extends BeanModel {
this.id
])

let promiseList = [];

let text;
if (bean.status === 1) {
text = "✅ Up"
Expand All @@ -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 {
Expand Down

0 comments on commit 03b3bb5

Please sign in to comment.