From 8730ee9de25243ace97af38ec893384489c14fca Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Mon, 28 Oct 2024 15:37:21 +0800 Subject: [PATCH] Fix concurrency error with updating monitor, uncomment out code in pageSpeedMonitorSlice --- Server/db/mongo/modules/monitorModule.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Server/db/mongo/modules/monitorModule.js b/Server/db/mongo/modules/monitorModule.js index 6aefefad5..b5abf19d1 100644 --- a/Server/db/mongo/modules/monitorModule.js +++ b/Server/db/mongo/modules/monitorModule.js @@ -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";