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
This commit is contained in:
Michael Auerswald 2023-11-14 11:04:24 +01:00 committed by GitHub
parent 9b3be0cfd8
commit 0e00dab9f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,6 +23,7 @@ import type {
IWorkflowSettings, IWorkflowSettings,
WorkflowExecuteMode, WorkflowExecuteMode,
ExecutionStatus, ExecutionStatus,
ExecutionError,
} from 'n8n-workflow'; } from 'n8n-workflow';
import { import {
ErrorReporterProxy as ErrorReporter, ErrorReporterProxy as ErrorReporter,
@ -902,10 +903,11 @@ async function executeWorkflow(
} }
data = await workflowExecute.processRunExecutionData(workflow); data = await workflowExecute.processRunExecutionData(workflow);
} catch (error) { } catch (error) {
const executionError = error ? (error as ExecutionError) : undefined;
const fullRunData: IRun = { const fullRunData: IRun = {
data: { data: {
resultData: { resultData: {
error, error: executionError,
runData: {}, runData: {},
}, },
}, },
@ -941,9 +943,9 @@ async function executeWorkflow(
); );
throw objectToError( throw objectToError(
{ {
...error, ...executionError,
stack: error.stack, stack: executionError?.stack,
message: error.message, message: executionError?.message,
}, },
workflow, workflow,
); );
@ -953,7 +955,8 @@ async function executeWorkflow(
void internalHooks.onWorkflowPostExecute(executionId, workflowData, data, additionalData.userId); 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 // Workflow did finish successfully
activeExecutions.remove(executionId, data); activeExecutions.remove(executionId, data);
@ -961,13 +964,14 @@ async function executeWorkflow(
return returnData!.data!.main; return returnData!.data!.main;
} }
activeExecutions.remove(executionId, data); activeExecutions.remove(executionId, data);
// Workflow did fail // Workflow did fail
const { error } = data.data.resultData; const { error } = data.data.resultData;
throw objectToError( throw objectToError(
{ {
...error, ...error,
stack: error!.stack, stack: error?.stack,
}, },
workflow, workflow,
); );