From 0e00dab9f5d5a6622cdc22fa8bfbecc039f6b67a Mon Sep 17 00:00:00 2001 From: Michael Auerswald Date: Tue, 14 Nov 2023 11:04:24 +0100 Subject: [PATCH] fix(core): Consider subworkflows successfully run when in waiting state (#7699) Github issue / Community forum post (link here to close automatically): https://github.com/n8n-io/n8n/issues/7189 --- .../cli/src/WorkflowExecuteAdditionalData.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/cli/src/WorkflowExecuteAdditionalData.ts b/packages/cli/src/WorkflowExecuteAdditionalData.ts index 2e506b2032..73a533a2e0 100644 --- a/packages/cli/src/WorkflowExecuteAdditionalData.ts +++ b/packages/cli/src/WorkflowExecuteAdditionalData.ts @@ -23,6 +23,7 @@ import type { IWorkflowSettings, WorkflowExecuteMode, ExecutionStatus, + ExecutionError, } from 'n8n-workflow'; import { ErrorReporterProxy as ErrorReporter, @@ -902,10 +903,11 @@ async function executeWorkflow( } data = await workflowExecute.processRunExecutionData(workflow); } catch (error) { + const executionError = error ? (error as ExecutionError) : undefined; const fullRunData: IRun = { data: { resultData: { - error, + error: executionError, runData: {}, }, }, @@ -941,9 +943,9 @@ async function executeWorkflow( ); throw objectToError( { - ...error, - stack: error.stack, - message: error.message, + ...executionError, + stack: executionError?.stack, + message: executionError?.message, }, workflow, ); @@ -953,7 +955,8 @@ async function executeWorkflow( void internalHooks.onWorkflowPostExecute(executionId, workflowData, data, additionalData.userId); - if (data.finished === true) { + // subworkflow either finished, or is in status waiting due to a wait node, both cases are considered successes here + if (data.finished === true || data.status === 'waiting') { // Workflow did finish successfully activeExecutions.remove(executionId, data); @@ -961,13 +964,14 @@ async function executeWorkflow( return returnData!.data!.main; } activeExecutions.remove(executionId, data); + // Workflow did fail const { error } = data.data.resultData; throw objectToError( { ...error, - stack: error!.stack, + stack: error?.stack, }, workflow, );