From 042b8daf1cd16822e2da03cf18a69091477d4451 Mon Sep 17 00:00:00 2001 From: Omar Ajoue Date: Thu, 2 Jun 2022 12:17:24 +0200 Subject: [PATCH] fix(core): Fix crashes in queue mode (#3397) * Add catch block to avoid crashes when running in queue mode * Throwing errors that happen in worker so process stops --- packages/cli/commands/worker.ts | 1 + packages/cli/src/WorkflowRunner.ts | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/packages/cli/commands/worker.ts b/packages/cli/commands/worker.ts index 424d5c71b0..cf07c190d3 100644 --- a/packages/cli/commands/worker.ts +++ b/packages/cli/commands/worker.ts @@ -354,6 +354,7 @@ export class Worker extends Command { process.exit(2); } else { logger.error('Error from queue: ', error); + throw error; } }); diff --git a/packages/cli/src/WorkflowRunner.ts b/packages/cli/src/WorkflowRunner.ts index 495a37c6f7..cc3b0d7fca 100644 --- a/packages/cli/src/WorkflowRunner.ts +++ b/packages/cli/src/WorkflowRunner.ts @@ -561,6 +561,12 @@ export class WorkflowRunner { }, ); + workflowExecution.catch(() => { + // We `reject` this promise if the execution fails + // but the error is handled already by processError + // So we're just preventing crashes here. + }); + this.activeExecutions.attachWorkflowExecution(executionId, workflowExecution); return executionId; }