Skip to content

Commit

Permalink
Refactor timeout handling in monitor types to return null instead of …
Browse files Browse the repository at this point in the history
…failure response
  • Loading branch information
simlarsen committed Sep 23, 2024
1 parent 063b9b3 commit 7b02c6d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 13 deletions.
3 changes: 1 addition & 2 deletions Probe/Utils/Monitors/MonitorTypes/ApiMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ export default class ApiMonitor {
`API Monitor - Timeout exceeded ${options.monitorId?.toString()} ${requestType} ${url.toString()} - ERROR: ${err}`,
);

apiResponse.failureCause = "Timeout exceeded";
apiResponse.isOnline = false;
return null; // timeout exceeded
}

logger.error(
Expand Down
5 changes: 1 addition & 4 deletions Probe/Utils/Monitors/MonitorTypes/PingMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ export default class PingMonitor {
`Ping Monitor - Timeout exceeded ${pingOptions.monitorId?.toString()} ${host.toString()} - ERROR: ${err}`,
);

return {
isOnline: false,
failureCause: "Host is not reachable. Timeout exceeded.",
};
return null;
}

// check if the probe is online.
Expand Down
5 changes: 1 addition & 4 deletions Probe/Utils/Monitors/MonitorTypes/SslMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ export default class SSLMonitor {
`Ping Monitor - Timeout exceeded ${pingOptions.monitorId?.toString()} ${url.toString()} - ERROR: ${err}`,
);

return {
isOnline: false,
failureCause: "Timeout exceeded",
};
return null;
}

// check if the probe is online.
Expand Down
4 changes: 1 addition & 3 deletions Probe/Utils/Monitors/MonitorTypes/WebsiteMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,8 @@ export default class WebsiteMonitor {
logger.debug(
`Website Monitor - Timeout exceeded ${options.monitorId?.toString()} ${requestType} ${url.toString()} - ERROR: ${err}`,
);
probeWebsiteResponse.failureCause = "Timeout exceeded";
probeWebsiteResponse.isOnline = false;

return probeWebsiteResponse;
return null;
}

if (!options.isOnlineCheckRequest) {
Expand Down

0 comments on commit 7b02c6d

Please sign in to comment.