Move opeartion back to

This commit is contained in:
Alex Holliday
2024-10-18 14:21:22 +08:00
parent f5265b140c
commit 64d2d9b3ce

View File

@@ -138,10 +138,13 @@ class NetworkService {
async handlePing(job) {
let isAlive;
const operation = async () => {
const response = await this.ping.promise.probe(job.data.url);
return response;
};
try {
const { responseTime, response } = await this.measureResponseTime(
this.ping.promise.probe(job.data.url)
);
const { responseTime, response } = await this.measureResponseTime(operation);
isAlive = response.alive;
const checkData = {
monitorId: job.data._id,
@@ -206,6 +209,7 @@ class NetworkService {
responseTime: error.responseTime,
message,
};
await this.logAndStoreCheck(checkData, this.db.createCheck);
} finally {
this.handleStatusUpdate(job, isAlive);
}