fix: Expose worker errors with stack trace

This commit is contained in:
Faruk AYDIN
2023-04-07 18:16:08 +02:00
parent 20c5d6aee1
commit 4aa41773c4
5 changed files with 50 additions and 28 deletions

View File

@@ -23,9 +23,8 @@ const DEFAULT_DELAY_DURATION = 0;
export const worker = new Worker(
'action',
async (job) => {
const { stepId, flowId, executionId, computedParameters, executionStep } = await processAction(
job.data as JobData
);
const { stepId, flowId, executionId, computedParameters, executionStep } =
await processAction(job.data as JobData);
const step = await Step.query().findById(stepId).throwIfNotFound();
const nextStep = await step.getNextStep();
@@ -64,14 +63,17 @@ worker.on('completed', (job) => {
});
worker.on('failed', (job, err) => {
logger.info(
`JOB ID: ${job.id} - FLOW ID: ${job.data.flowId} has failed to start with ${err.message}`
);
const errorMessage = `
JOB ID: ${job.id} - FLOW ID: ${job.data.flowId} has failed to start with ${err.message}
\n ${err.stack}
`;
logger.error(errorMessage);
Sentry.captureException(err, {
extra: {
jobId: job.id,
}
},
});
});