mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 02:51:14 +00:00
feat(core): Improve debugging of sub-workflows (#11602)
This commit is contained in:
@@ -36,6 +36,8 @@ import type {
|
||||
ExecuteWorkflowOptions,
|
||||
IWorkflowExecutionDataProcess,
|
||||
EnvProviderState,
|
||||
ExecuteWorkflowData,
|
||||
RelatedExecution,
|
||||
} from 'n8n-workflow';
|
||||
import { Container } from 'typedi';
|
||||
|
||||
@@ -45,11 +47,7 @@ import { CredentialsHelper } from '@/credentials-helper';
|
||||
import { ExecutionRepository } from '@/databases/repositories/execution.repository';
|
||||
import type { AiEventMap, AiEventPayload } from '@/events/maps/ai.event-map';
|
||||
import { ExternalHooks } from '@/external-hooks';
|
||||
import type {
|
||||
IWorkflowExecuteProcess,
|
||||
IWorkflowErrorData,
|
||||
UpdateExecutionPayload,
|
||||
} from '@/interfaces';
|
||||
import type { IWorkflowErrorData, UpdateExecutionPayload } from '@/interfaces';
|
||||
import { NodeTypes } from '@/node-types';
|
||||
import { Push } from '@/push';
|
||||
import { WorkflowStatisticsService } from '@/services/workflow-statistics.service';
|
||||
@@ -650,6 +648,7 @@ function hookFunctionsSaveWorker(): IWorkflowExecuteHooks {
|
||||
export async function getRunData(
|
||||
workflowData: IWorkflowBase,
|
||||
inputData?: INodeExecutionData[],
|
||||
parentExecution?: RelatedExecution,
|
||||
): Promise<IWorkflowExecutionDataProcess> {
|
||||
const mode = 'integrated';
|
||||
|
||||
@@ -669,6 +668,7 @@ export async function getRunData(
|
||||
data: {
|
||||
main: [inputData],
|
||||
},
|
||||
metadata: { parentExecution },
|
||||
source: null,
|
||||
});
|
||||
|
||||
@@ -740,7 +740,41 @@ export async function executeWorkflow(
|
||||
workflowInfo: IExecuteWorkflowInfo,
|
||||
additionalData: IWorkflowExecuteAdditionalData,
|
||||
options: ExecuteWorkflowOptions,
|
||||
): Promise<Array<INodeExecutionData[] | null> | IWorkflowExecuteProcess> {
|
||||
): Promise<ExecuteWorkflowData> {
|
||||
const activeExecutions = Container.get(ActiveExecutions);
|
||||
|
||||
const workflowData =
|
||||
options.loadedWorkflowData ??
|
||||
(await getWorkflowData(workflowInfo, options.parentWorkflowId, options.parentWorkflowSettings));
|
||||
|
||||
const runData =
|
||||
options.loadedRunData ??
|
||||
(await getRunData(workflowData, options.inputData, options.parentExecution));
|
||||
|
||||
const executionId = await activeExecutions.add(runData);
|
||||
|
||||
const executionPromise = startExecution(
|
||||
additionalData,
|
||||
options,
|
||||
executionId,
|
||||
runData,
|
||||
workflowData,
|
||||
);
|
||||
|
||||
if (options.doNotWaitToFinish) {
|
||||
return { executionId, data: [null] };
|
||||
}
|
||||
|
||||
return await executionPromise;
|
||||
}
|
||||
|
||||
async function startExecution(
|
||||
additionalData: IWorkflowExecuteAdditionalData,
|
||||
options: ExecuteWorkflowOptions,
|
||||
executionId: string,
|
||||
runData: IWorkflowExecutionDataProcess,
|
||||
workflowData: IWorkflowBase,
|
||||
): Promise<ExecuteWorkflowData> {
|
||||
const externalHooks = Container.get(ExternalHooks);
|
||||
await externalHooks.init();
|
||||
|
||||
@@ -749,10 +783,6 @@ export async function executeWorkflow(
|
||||
const eventService = Container.get(EventService);
|
||||
const executionRepository = Container.get(ExecutionRepository);
|
||||
|
||||
const workflowData =
|
||||
options.loadedWorkflowData ??
|
||||
(await getWorkflowData(workflowInfo, options.parentWorkflowId, options.parentWorkflowSettings));
|
||||
|
||||
const workflowName = workflowData ? workflowData.name : undefined;
|
||||
const workflow = new Workflow({
|
||||
id: workflowData.id,
|
||||
@@ -765,10 +795,6 @@ export async function executeWorkflow(
|
||||
settings: workflowData.settings,
|
||||
});
|
||||
|
||||
const runData = options.loadedRunData ?? (await getRunData(workflowData, options.inputData));
|
||||
|
||||
const executionId = await activeExecutions.add(runData);
|
||||
|
||||
/**
|
||||
* A subworkflow execution in queue mode is not enqueued, but rather runs in the
|
||||
* same worker process as the parent execution. Hence ensure the subworkflow
|
||||
@@ -890,7 +916,10 @@ export async function executeWorkflow(
|
||||
|
||||
activeExecutions.finalizeExecution(executionId, data);
|
||||
const returnData = WorkflowHelpers.getDataLastExecutedNodeData(data);
|
||||
return returnData!.data!.main;
|
||||
return {
|
||||
executionId,
|
||||
data: returnData!.data!.main,
|
||||
};
|
||||
}
|
||||
activeExecutions.finalizeExecution(executionId, data);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user