fix(core): Add logs and error catches for possible failures in queue mode (#3032)

This commit is contained in:
Omar Ajoue 2022-03-25 15:10:31 +01:00 committed by GitHub
parent f6aa8f2196
commit 3b4a97dd57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -119,9 +119,14 @@ export class Worker extends Command {
async runJob(job: Bull.Job, nodeTypes: INodeTypes): Promise<IBullJobResponse> {
const jobData = job.data as IBullJobData;
const executionDb = (await Db.collections.Execution!.findOne(
jobData.executionId,
)) as IExecutionFlattedDb;
const executionDb = await Db.collections.Execution!.findOne(jobData.executionId);
if (!executionDb) {
LoggerProxy.error('Worker failed to find execution data in database. Cannot continue.', {
executionId: jobData.executionId,
});
throw new Error('Unable to find execution data in database. Aborting execution.');
}
const currentExecutionDb = ResponseHelper.unflattenExecutionData(executionDb);
LoggerProxy.info(
`Start job: ${job.id} (Workflow ID: ${currentExecutionDb.workflowData.id} | Execution: ${jobData.executionId})`,
@ -139,6 +144,13 @@ export class Worker extends Command {
findOptions,
);
if (workflowData === undefined) {
LoggerProxy.error(
'Worker execution failed because workflow could not be found in database.',
{
workflowId: currentExecutionDb.workflowData.id,
executionId: jobData.executionId,
},
);
throw new Error(
`The workflow with the ID "${currentExecutionDb.workflowData.id}" could not be found`,
);