From f9699bb9cd2813369703a5a9dd56e38823ec223c Mon Sep 17 00:00:00 2001 From: Omar Ajoue Date: Wed, 23 Mar 2022 11:22:15 +0100 Subject: [PATCH] Added logs and error catches for possible failures in queue mode --- packages/cli/commands/worker.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/cli/commands/worker.ts b/packages/cli/commands/worker.ts index 1f3f3b9fe0a70..06a4f2e6fe7c2 100644 --- a/packages/cli/commands/worker.ts +++ b/packages/cli/commands/worker.ts @@ -119,9 +119,14 @@ export class Worker extends Command { async runJob(job: Bull.Job, nodeTypes: INodeTypes): Promise { 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`, );