mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
fix: handle AggregateError in monitors and return detailed failure responses
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user