Skip to content

Commit

Permalink
fix(core): Add logs and error catches for possible failures in queue …
Browse files Browse the repository at this point in the history
…mode (#3032)
  • Loading branch information
krynble committed Mar 25, 2022
1 parent f6aa8f2 commit 3b4a97d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/cli/commands/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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})`,
Expand All @@ -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`,
);
Expand Down

0 comments on commit 3b4a97d

Please sign in to comment.