fix(core): Update subworkflow execution status correctly (#10764)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-09-11 10:39:18 +02:00
committed by GitHub
parent b9d157db40
commit 4f94319cd9
16 changed files with 51 additions and 78 deletions

View File

@@ -24,7 +24,8 @@ import type {
ExecutionStatus,
ExecutionError,
EventNamesAiNodesType,
CallbackManager,
ExecuteWorkflowOptions,
IWorkflowExecutionDataProcess,
} from 'n8n-workflow';
import {
ApplicationError,
@@ -42,7 +43,6 @@ import { ExternalHooks } from '@/external-hooks';
import type {
IPushDataExecutionFinished,
IWorkflowExecuteProcess,
IWorkflowExecutionDataProcess,
IWorkflowErrorData,
IPushDataType,
ExecutionPayload,
@@ -714,13 +714,11 @@ export async function getRunData(
},
};
const runData: IWorkflowExecutionDataProcess = {
return {
executionMode: mode,
executionData: runExecutionData,
workflowData,
};
return runData;
}
export async function getWorkflowData(
@@ -769,16 +767,7 @@ export async function getWorkflowData(
async function executeWorkflow(
workflowInfo: IExecuteWorkflowInfo,
additionalData: IWorkflowExecuteAdditionalData,
options: {
node?: INode;
parentWorkflowId: string;
inputData?: INodeExecutionData[];
parentExecutionId?: string;
loadedWorkflowData?: IWorkflowBase;
loadedRunData?: IWorkflowExecutionDataProcess;
parentWorkflowSettings?: IWorkflowSettings;
parentCallbackManager?: CallbackManager;
},
options: ExecuteWorkflowOptions,
): Promise<Array<INodeExecutionData[] | null> | IWorkflowExecuteProcess> {
const externalHooks = Container.get(ExternalHooks);
await externalHooks.init();
@@ -786,6 +775,7 @@ async function executeWorkflow(
const nodeTypes = Container.get(NodeTypes);
const activeExecutions = Container.get(ActiveExecutions);
const eventService = Container.get(EventService);
const executionRepository = Container.get(ExecutionRepository);
const workflowData =
options.loadedWorkflowData ??
@@ -805,13 +795,8 @@ async function executeWorkflow(
const runData = options.loadedRunData ?? (await getRunData(workflowData, options.inputData));
let executionId;
if (options.parentExecutionId !== undefined) {
executionId = options.parentExecutionId;
} else {
executionId = options.parentExecutionId ?? (await activeExecutions.add(runData));
}
const executionId = await activeExecutions.add(runData);
await executionRepository.updateStatus(executionId, 'running');
Container.get(EventService).emit('workflow-pre-execute', { executionId, data: runData });
@@ -862,14 +847,6 @@ async function executeWorkflow(
runData.executionMode,
runExecutionData,
);
if (options.parentExecutionId !== undefined) {
// Must be changed to become typed
return {
startedAt: new Date(),
workflow,
workflowExecute,
};
}
const execution = workflowExecute.processRunExecutionData(workflow);
activeExecutions.attachWorkflowExecution(executionId, execution);
data = await execution;
@@ -909,10 +886,7 @@ async function executeWorkflow(
// remove execution from active executions
activeExecutions.remove(executionId, fullRunData);
await Container.get(ExecutionRepository).updateExistingExecution(
executionId,
fullExecutionData,
);
await executionRepository.updateExistingExecution(executionId, fullExecutionData);
throw objectToError(
{
...executionError,