Fix concurrency error with updating monitor, uncomment out code in pageSpeedMonitorSlice

This commit is contained in:
Alex Holliday committed 2024-10-28 15:37:21 +08:00
1 parent 86ab22df03
commit 8730ee9de2
1 file changed
+6 -3
+6 -3
View File
@@ -296,9 +296,12 @@ const getMonitorById = async (monitorId) => {
const notifications = await Notification.find({
monitorId: monitorId,
});
monitor.notifications = notifications;
const monitorWithNotifications = await monitor.save();
return monitorWithNotifications;
const updatedMonitor = await Monitor.findByIdAndUpdate(
monitorId,
{ notifications },
{ new: true }
).populate("notifications");
return updatedMonitor;
} catch (error) {
error.service = SERVICE_NAME;
error.method = "getMonitorById";