feat(monitors): track and report bulk action queue failures

Addresses PR feedback:
- Upgrades bulk pausing from Promise.all to Promise.allSettled
- Logs individual job queue sync failures with monitor ID context
- Surfaces failedCount to the frontend via controller response
- Adds unit tests to verify partial failure handling

Fixes #3602
This commit is contained in:
harsh-aghara committed 2026-05-05 17:08:25 +05:30
1 parent baf7344e2d
commit e725128b10
3 files changed
+82 -11

No files matched your search

+7 -2
View File
@@ -315,14 +315,19 @@ class MonitorController implements IMonitorController {
const { monitorIds, pause } = validatedBody;
const teamId = requireTeamId(req.user?.teamId);
const monitors = await this.monitorService.bulkPauseMonitors({ teamId, monitorIds, pause });
const { monitors, failedCount } = await this.monitorService.bulkPauseMonitors({ teamId, monitorIds, pause });
const action = pause ? "paused" : "resumed";
const monitorStr = monitors.length === 1 ? "monitor" : "monitors";
let msg = `${monitors.length} ${monitorStr} ${action} successfully`;
if (failedCount > 0) {
msg = `${monitors.length} ${monitorStr} ${action} in database, but ${failedCount} failed to sync with the job queue. Please check logs.`;
}
return res.status(200).json({
success: true,
msg: `${monitors.length} ${monitorStr} ${action} successfully`,
msg,
data: monitors,
});
} catch (error) {