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

feat: jobqueue error handling
This commit is contained in:
Alexander Holliday authored and GitHub committed 2025-05-20 13:23:50 -07:00
commit 62e259e3e6
3 files changed
+13 -28

No files matched your search

+6 -11
View File
@@ -143,10 +143,11 @@ class JobQueueHelper {
}); });
worker.on("failed", (job, error, prev) => { worker.on("failed", (job, error, prev) => {
this.logger.warn({ this.logger.error({
message: `Worker ${queueName} is failed with msg: ${error}`, message: `Worker ${queueName} is failed with msg: ${error.message}`,
service: SERVICE_NAME, service: error?.service ?? SERVICE_NAME,
method: "createWorker:failed", method: error?.method ?? "createWorker:failed",
stack: error?.stack,
}); });
}); });
@@ -293,13 +294,7 @@ class JobQueueHelper {
await job.updateProgress(100); await job.updateProgress(100);
return true; return true;
} catch (error) { } catch (error) {
this.logger.error({ await job.updateProgress(100);
message: error.message,
service: error.service ?? SERVICE_NAME,
method: error.method ?? "createJobHandler",
details: `Error processing job ${job.id}: ${error.message}`,
stack: error.stack,
});
throw error; throw error;
} }
}; };
-6
View File
@@ -437,12 +437,6 @@ class NetworkService {
throw new Error(response.data.message); throw new Error(response.data.message);
} }
} catch (error) { } catch (error) {
this.logger.error({
message: "Error in requestDistributedHttp",
service: this.SERVICE_NAME,
method: "requestDistributedHttp",
stack: error.stack,
});
error.service = this.SERVICE_NAME; error.service = this.SERVICE_NAME;
error.method = "requestDistributedHttp"; error.method = "requestDistributedHttp";
throw error; throw error;
+7 -11
View File
@@ -121,10 +121,10 @@ class StatusService {
try { try {
const { monitorId, status, code } = networkResponse; const { monitorId, status, code } = networkResponse;
const monitor = await this.db.getMonitorById(monitorId); const monitor = await this.db.getMonitorById(monitorId);
// Update running stats // Update running stats
this.updateRunningStats({ monitor, networkResponse }); this.updateRunningStats({ monitor, networkResponse });
// No change in monitor status, return early // No change in monitor status, return early
if (monitor.status === status) if (monitor.status === status)
return { return {
@@ -134,7 +134,7 @@ class StatusService {
code, code,
timestamp: new Date().getTime(), timestamp: new Date().getTime(),
}; };
// Monitor status changed, save prev status and update monitor // Monitor status changed, save prev status and update monitor
this.logger.info({ this.logger.info({
service: this.SERVICE_NAME, service: this.SERVICE_NAME,
@@ -144,11 +144,11 @@ class StatusService {
prevStatus: monitor.status, prevStatus: monitor.status,
newStatus: status, newStatus: status,
}); });
const prevStatus = monitor.status; const prevStatus = monitor.status;
monitor.status = status; monitor.status = status;
await monitor.save(); await monitor.save();
return { return {
monitor, monitor,
statusChanged: true, statusChanged: true,
@@ -157,12 +157,8 @@ class StatusService {
timestamp: new Date().getTime(), timestamp: new Date().getTime(),
}; };
} catch (error) { } catch (error) {
this.logger.error({ error.service = this.SERVICE_NAME;
service: this.SERVICE_NAME, error.method = "updateStatus";
message: error.message,
method: "updateStatus",
stack: error.stack,
});
throw error; throw error;
} }
}; };