fix: Expose worker errors with stack trace
This commit is contained in:
@@ -23,9 +23,8 @@ const DEFAULT_DELAY_DURATION = 0;
|
|||||||
export const worker = new Worker(
|
export const worker = new Worker(
|
||||||
'action',
|
'action',
|
||||||
async (job) => {
|
async (job) => {
|
||||||
const { stepId, flowId, executionId, computedParameters, executionStep } = await processAction(
|
const { stepId, flowId, executionId, computedParameters, executionStep } =
|
||||||
job.data as JobData
|
await processAction(job.data as JobData);
|
||||||
);
|
|
||||||
|
|
||||||
const step = await Step.query().findById(stepId).throwIfNotFound();
|
const step = await Step.query().findById(stepId).throwIfNotFound();
|
||||||
const nextStep = await step.getNextStep();
|
const nextStep = await step.getNextStep();
|
||||||
@@ -64,14 +63,17 @@ worker.on('completed', (job) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
worker.on('failed', (job, err) => {
|
worker.on('failed', (job, err) => {
|
||||||
logger.info(
|
const errorMessage = `
|
||||||
`JOB ID: ${job.id} - FLOW ID: ${job.data.flowId} has failed to start with ${err.message}`
|
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, {
|
Sentry.captureException(err, {
|
||||||
extra: {
|
extra: {
|
||||||
jobId: job.id,
|
jobId: job.id,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -18,7 +18,9 @@ export const worker = new Worker(
|
|||||||
await user.$relatedQuery('executions').select('executions.id')
|
await user.$relatedQuery('executions').select('executions.id')
|
||||||
).map((execution: Execution) => execution.id);
|
).map((execution: Execution) => execution.id);
|
||||||
|
|
||||||
await ExecutionStep.query().hardDelete().whereIn('execution_id', executionIds);
|
await ExecutionStep.query()
|
||||||
|
.hardDelete()
|
||||||
|
.whereIn('execution_id', executionIds);
|
||||||
await user.$relatedQuery('executions').hardDelete();
|
await user.$relatedQuery('executions').hardDelete();
|
||||||
await user.$relatedQuery('steps').hardDelete();
|
await user.$relatedQuery('steps').hardDelete();
|
||||||
await user.$relatedQuery('flows').hardDelete();
|
await user.$relatedQuery('flows').hardDelete();
|
||||||
@@ -36,14 +38,17 @@ worker.on('completed', (job) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
worker.on('failed', (job, err) => {
|
worker.on('failed', (job, err) => {
|
||||||
logger.info(
|
const errorMessage = `
|
||||||
`JOB ID: ${job.id} - The user with the ID of '${job.data.id}' has failed to be deleted! ${err.message}`
|
JOB ID: ${job.id} - The user with the ID of '${job.data.id}' has failed to be deleted! ${err.message}
|
||||||
);
|
\n ${err.stack}
|
||||||
|
`;
|
||||||
|
|
||||||
|
logger.error(errorMessage);
|
||||||
|
|
||||||
Sentry.captureException(err, {
|
Sentry.captureException(err, {
|
||||||
extra: {
|
extra: {
|
||||||
jobId: job.id,
|
jobId: job.id,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -29,14 +29,17 @@ worker.on('completed', (job) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
worker.on('failed', (job, err) => {
|
worker.on('failed', (job, err) => {
|
||||||
logger.info(
|
const errorMessage = `
|
||||||
`JOB ID: ${job.id} - ${job.data.subject} email to ${job.data.email} has failed to send with ${err.message}`
|
JOB ID: ${job.id} - ${job.data.subject} email to ${job.data.email} has failed to send with ${err.message}
|
||||||
);
|
\n ${err.stack}
|
||||||
|
`;
|
||||||
|
|
||||||
|
logger.error(errorMessage);
|
||||||
|
|
||||||
Sentry.captureException(err, {
|
Sentry.captureException(err, {
|
||||||
extra: {
|
extra: {
|
||||||
jobId: job.id,
|
jobId: job.id,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -6,7 +6,10 @@ import logger from '../helpers/logger';
|
|||||||
import triggerQueue from '../queues/trigger';
|
import triggerQueue from '../queues/trigger';
|
||||||
import { processFlow } from '../services/flow';
|
import { processFlow } from '../services/flow';
|
||||||
import Flow from '../models/flow';
|
import Flow from '../models/flow';
|
||||||
import { REMOVE_AFTER_30_DAYS_OR_150_JOBS, REMOVE_AFTER_7_DAYS_OR_50_JOBS } from '../helpers/remove-job-configuration';
|
import {
|
||||||
|
REMOVE_AFTER_30_DAYS_OR_150_JOBS,
|
||||||
|
REMOVE_AFTER_7_DAYS_OR_50_JOBS,
|
||||||
|
} from '../helpers/remove-job-configuration';
|
||||||
|
|
||||||
export const worker = new Worker(
|
export const worker = new Worker(
|
||||||
'flow',
|
'flow',
|
||||||
@@ -30,7 +33,7 @@ export const worker = new Worker(
|
|||||||
const jobOptions = {
|
const jobOptions = {
|
||||||
removeOnComplete: REMOVE_AFTER_7_DAYS_OR_50_JOBS,
|
removeOnComplete: REMOVE_AFTER_7_DAYS_OR_50_JOBS,
|
||||||
removeOnFail: REMOVE_AFTER_30_DAYS_OR_150_JOBS,
|
removeOnFail: REMOVE_AFTER_30_DAYS_OR_150_JOBS,
|
||||||
}
|
};
|
||||||
|
|
||||||
for (const triggerItem of reversedData) {
|
for (const triggerItem of reversedData) {
|
||||||
const jobName = `${triggerStep.id}-${triggerItem.meta.internalId}`;
|
const jobName = `${triggerStep.id}-${triggerItem.meta.internalId}`;
|
||||||
@@ -64,14 +67,17 @@ worker.on('completed', (job) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
worker.on('failed', (job, err) => {
|
worker.on('failed', (job, err) => {
|
||||||
logger.info(
|
const errorMessage = `
|
||||||
`JOB ID: ${job.id} - FLOW ID: ${job.data.flowId} has failed to start with ${err.message}`
|
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, {
|
Sentry.captureException(err, {
|
||||||
extra: {
|
extra: {
|
||||||
jobId: job.id,
|
jobId: job.id,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -7,7 +7,10 @@ import logger from '../helpers/logger';
|
|||||||
import actionQueue from '../queues/action';
|
import actionQueue from '../queues/action';
|
||||||
import Step from '../models/step';
|
import Step from '../models/step';
|
||||||
import { processTrigger } from '../services/trigger';
|
import { processTrigger } from '../services/trigger';
|
||||||
import { REMOVE_AFTER_30_DAYS_OR_150_JOBS, REMOVE_AFTER_7_DAYS_OR_50_JOBS } from '../helpers/remove-job-configuration';
|
import {
|
||||||
|
REMOVE_AFTER_30_DAYS_OR_150_JOBS,
|
||||||
|
REMOVE_AFTER_7_DAYS_OR_50_JOBS,
|
||||||
|
} from '../helpers/remove-job-configuration';
|
||||||
|
|
||||||
type JobData = {
|
type JobData = {
|
||||||
flowId: string;
|
flowId: string;
|
||||||
@@ -38,7 +41,7 @@ export const worker = new Worker(
|
|||||||
const jobOptions = {
|
const jobOptions = {
|
||||||
removeOnComplete: REMOVE_AFTER_7_DAYS_OR_50_JOBS,
|
removeOnComplete: REMOVE_AFTER_7_DAYS_OR_50_JOBS,
|
||||||
removeOnFail: REMOVE_AFTER_30_DAYS_OR_150_JOBS,
|
removeOnFail: REMOVE_AFTER_30_DAYS_OR_150_JOBS,
|
||||||
}
|
};
|
||||||
|
|
||||||
await actionQueue.add(jobName, jobPayload, jobOptions);
|
await actionQueue.add(jobName, jobPayload, jobOptions);
|
||||||
},
|
},
|
||||||
@@ -50,14 +53,17 @@ worker.on('completed', (job) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
worker.on('failed', (job, err) => {
|
worker.on('failed', (job, err) => {
|
||||||
logger.info(
|
const errorMessage = `
|
||||||
`JOB ID: ${job.id} - FLOW ID: ${job.data.flowId} has failed to start with ${err.message}`
|
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, {
|
Sentry.captureException(err, {
|
||||||
extra: {
|
extra: {
|
||||||
jobId: job.id,
|
jobId: job.id,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user