fix: handle AggregateError in monitors and return detailed failure responses

This commit is contained in:
Nawaz Dhandala
2026-03-04 21:28:03 +00:00
parent dc8f5b8160
commit 9444734e7f
4 changed files with 27 additions and 7 deletions

View File

@@ -179,7 +179,7 @@ export default class ApiMonitor {
logger.error(
`API Monitor - Probe is not online. Cannot ping ${options.monitorId?.toString()} ${requestType} ${url.toString()} - ERROR: ${err}`,
);
return null;
return null;
}
}
@@ -223,7 +223,11 @@ export default class ApiMonitor {
if (
API.getFriendlyErrorMessage(err as Error).includes("AggregateError")
) {
return null;
apiResponse.failureCause =
"Request failed with AggregateError (all connection attempts failed). " +
apiResponse.failureCause;
apiResponse.isOnline = false;
return apiResponse;
}
logger.error(

View File

@@ -122,7 +122,7 @@ export default class PingMonitor {
logger.error(
`PingMonitor Monitor - Probe is not online. Cannot ping ${pingOptions?.monitorId?.toString()} ${host.toString()} - ERROR: ${err}`,
);
return null;
return null;
}
}
@@ -147,7 +147,13 @@ export default class PingMonitor {
// if AggregateError is thrown, it means that the request failed
if ((err as any).toString().includes("AggregateError")) {
return null;
return {
isOnline: false,
isTimeout: false,
failureCause:
"Request failed with AggregateError (all connection attempts failed). " +
(err as any).toString(),
};
}
return {

View File

@@ -198,7 +198,7 @@ export default class PortMonitor {
logger.error(
`PortMonitor Monitor - Probe is not online. Cannot ping ${pingOptions?.monitorId?.toString()} ${host.toString()} - ERROR: ${err}`,
);
return null;
return null;
}
}
@@ -216,7 +216,13 @@ export default class PortMonitor {
// if AggregateError is thrown, it means that the request failed
if ((err as any).toString().includes("AggregateError")) {
return null;
return {
isOnline: false,
isTimeout: false,
failureCause:
"Request failed with AggregateError (all connection attempts failed). " +
(err as any).toString(),
};
}
return {

View File

@@ -213,7 +213,11 @@ export default class WebsiteMonitor {
if (
API.getFriendlyErrorMessage(err as Error).includes("AggregateError")
) {
return null;
probeWebsiteResponse.failureCause =
"Request failed with AggregateError (all connection attempts failed). " +
probeWebsiteResponse.failureCause;
probeWebsiteResponse.isOnline = false;
return probeWebsiteResponse;
}
logger.error(