diff --git a/packages/cli/src/WorkflowRunner.ts b/packages/cli/src/WorkflowRunner.ts index 518b7a4e12..07f9b91fe2 100644 --- a/packages/cli/src/WorkflowRunner.ts +++ b/packages/cli/src/WorkflowRunner.ts @@ -212,31 +212,31 @@ export class WorkflowRunner { workflowExecution = workflowExecute.runPartialWorkflow(workflow, data.runData, data.startNodes, data.destinationNode); } + this.activeExecutions.attachWorkflowExecution(executionId, workflowExecution); + + if (workflowTimeout > 0) { + const timeout = Math.min(workflowTimeout, config.get('executions.maxTimeout') as number) * 1000; // as seconds + executionTimeout = setTimeout(() => { + this.activeExecutions.stopExecution(executionId, 'timeout'); + }, timeout); + } + + workflowExecution.then((fullRunData) => { + clearTimeout(executionTimeout); + if (workflowExecution.isCanceled) { + fullRunData.finished = false; + } + this.activeExecutions.remove(executionId, fullRunData); + }).catch((error) => { + this.processError(error, new Date(), data.executionMode, executionId, additionalData.hooks); + }); + } catch (error) { await this.processError(error, new Date(), data.executionMode, executionId, additionalData.hooks); throw error; } - this.activeExecutions.attachWorkflowExecution(executionId, workflowExecution); - - if (workflowTimeout > 0) { - const timeout = Math.min(workflowTimeout, config.get('executions.maxTimeout') as number) * 1000; // as seconds - executionTimeout = setTimeout(() => { - this.activeExecutions.stopExecution(executionId, 'timeout'); - }, timeout); - } - - workflowExecution.then((fullRunData) => { - clearTimeout(executionTimeout); - if (workflowExecution.isCanceled) { - fullRunData.finished = false; - } - this.activeExecutions.remove(executionId, fullRunData); - }).catch((error) => { - this.processError(error, new Date(), data.executionMode, executionId, additionalData.hooks); - }); - return executionId; }