Merge pull request #2309 from bluewave-labs/feat/jobqueue-error-handling

feat: jobqueue error handling
This commit is contained in:
Alexander Holliday
2025-05-20 13:23:50 -07:00
committed by GitHub
3 changed files with 13 additions and 28 deletions

View File

@@ -143,10 +143,11 @@ class JobQueueHelper {
});
worker.on("failed", (job, error, prev) => {
this.logger.warn({
message: `Worker ${queueName} is failed with msg: ${error}`,
service: SERVICE_NAME,
method: "createWorker:failed",
this.logger.error({
message: `Worker ${queueName} is failed with msg: ${error.message}`,
service: error?.service ?? SERVICE_NAME,
method: error?.method ?? "createWorker:failed",
stack: error?.stack,
});
});
@@ -293,13 +294,7 @@ class JobQueueHelper {
await job.updateProgress(100);
return true;
} catch (error) {
this.logger.error({
message: error.message,
service: error.service ?? SERVICE_NAME,
method: error.method ?? "createJobHandler",
details: `Error processing job ${job.id}: ${error.message}`,
stack: error.stack,
});
await job.updateProgress(100);
throw error;
}
};

View File

@@ -437,12 +437,6 @@ class NetworkService {
throw new Error(response.data.message);
}
} catch (error) {
this.logger.error({
message: "Error in requestDistributedHttp",
service: this.SERVICE_NAME,
method: "requestDistributedHttp",
stack: error.stack,
});
error.service = this.SERVICE_NAME;
error.method = "requestDistributedHttp";
throw error;

View File

@@ -121,10 +121,10 @@ class StatusService {
try {
const { monitorId, status, code } = networkResponse;
const monitor = await this.db.getMonitorById(monitorId);
// Update running stats
this.updateRunningStats({ monitor, networkResponse });
// No change in monitor status, return early
if (monitor.status === status)
return {
@@ -134,7 +134,7 @@ class StatusService {
code,
timestamp: new Date().getTime(),
};
// Monitor status changed, save prev status and update monitor
this.logger.info({
service: this.SERVICE_NAME,
@@ -144,11 +144,11 @@ class StatusService {
prevStatus: monitor.status,
newStatus: status,
});
const prevStatus = monitor.status;
monitor.status = status;
await monitor.save();
return {
monitor,
statusChanged: true,
@@ -157,12 +157,8 @@ class StatusService {
timestamp: new Date().getTime(),
};
} catch (error) {
this.logger.error({
service: this.SERVICE_NAME,
message: error.message,
method: "updateStatus",
stack: error.stack,
});
error.service = this.SERVICE_NAME;
error.method = "updateStatus";
throw error;
}
};