Skip to content

Node.js based forum software built for the modern web

fix: catch exceptions from sendNotifications

Barış Soner Uşaklıc1ec20470b97
diff --git a/src/messaging/notifications.js b/src/messaging/notifications.js
index 52fcecce8c..1c04d4562d 100644
--- a/src/messaging/notifications.js
+++ b/src/messaging/notifications.js
@@ -1,5 +1,7 @@
'use strict';
+const winston = require('winston');
+
const user = require('../user');
const notifications = require('../notifications');
const sockets = require('../socket.io');
@@ -45,8 +47,12 @@ module.exports = function (Messaging) {
Messaging.notifyQueue[`${fromUid}:${roomId}`] = queueObj;
}
- queueObj.timeout = setTimeout(() => {
- sendNotifications(fromUid, uids, roomId, queueObj.message);
+ queueObj.timeout = setTimeout(async () => {
+ try {
+ await sendNotifications(fromUid, uids, roomId, queueObj.message);
+ } catch (err) {
+ winston.error(`[messaging/notifications] Unabled to send notification\n${err.stack}`);
+ }
}, meta.config.notificationSendDelay * 1000);
};