mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 19:11:13 +00:00
refactor(core): Extract setup logic, group variables and document potential dead code (#18868)
This commit is contained in:
@@ -64,6 +64,7 @@ import { WorkflowHasIssuesError } from '@/errors/workflow-has-issues.error';
|
|||||||
import * as NodeExecuteFunctions from '@/node-execute-functions';
|
import * as NodeExecuteFunctions from '@/node-execute-functions';
|
||||||
import { isJsonCompatible } from '@/utils/is-json-compatible';
|
import { isJsonCompatible } from '@/utils/is-json-compatible';
|
||||||
|
|
||||||
|
import type { ExecutionLifecycleHooks } from './execution-lifecycle-hooks';
|
||||||
import { ExecuteContext, PollContext } from './node-execution-context';
|
import { ExecuteContext, PollContext } from './node-execution-context';
|
||||||
import {
|
import {
|
||||||
DirectedGraph,
|
DirectedGraph,
|
||||||
@@ -1534,6 +1535,25 @@ export class WorkflowExecute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private setupExecution(): {
|
||||||
|
startedAt: Date;
|
||||||
|
hooks: ExecutionLifecycleHooks;
|
||||||
|
} {
|
||||||
|
this.status = 'running';
|
||||||
|
|
||||||
|
const { hooks } = this.additionalData;
|
||||||
|
assert.ok(hooks, 'Failed to run workflow due to missing execution lifecycle hooks');
|
||||||
|
|
||||||
|
// NOTE: As far as I can tell this code is dead.
|
||||||
|
// FIXME: Fix the types to make sure startData is always set and remove the
|
||||||
|
// code.
|
||||||
|
if (this.runExecutionData.startData === undefined) {
|
||||||
|
this.runExecutionData.startData = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return { startedAt: new Date(), hooks };
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs the given execution data.
|
* Runs the given execution data.
|
||||||
*
|
*
|
||||||
@@ -1544,27 +1564,15 @@ export class WorkflowExecute {
|
|||||||
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
||||||
processRunExecutionData(workflow: Workflow): PCancelable<IRun> {
|
processRunExecutionData(workflow: Workflow): PCancelable<IRun> {
|
||||||
Logger.debug('Workflow execution started', { workflowId: workflow.id });
|
Logger.debug('Workflow execution started', { workflowId: workflow.id });
|
||||||
|
const { startedAt, hooks } = this.setupExecution();
|
||||||
const startedAt = new Date();
|
this.checkForWorkflowIssues(workflow);
|
||||||
|
this.handleWaitingState(workflow);
|
||||||
this.status = 'running';
|
|
||||||
|
|
||||||
const { hooks } = this.additionalData;
|
|
||||||
assert.ok(hooks, 'Failed to run workflow due to missing execution lifecycle hooks');
|
|
||||||
|
|
||||||
// Variables which hold temporary data for each node-execution
|
// Variables which hold temporary data for each node-execution
|
||||||
let executionData: IExecuteData;
|
let executionData: IExecuteData;
|
||||||
let executionError: ExecutionBaseError | undefined;
|
let executionError: ExecutionBaseError | undefined;
|
||||||
let executionNode: INode;
|
let executionNode: INode;
|
||||||
let runIndex: number;
|
let runIndex: number;
|
||||||
|
|
||||||
if (this.runExecutionData.startData === undefined) {
|
|
||||||
this.runExecutionData.startData = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
this.checkForWorkflowIssues(workflow);
|
|
||||||
this.handleWaitingState(workflow);
|
|
||||||
|
|
||||||
let currentExecutionTry = '';
|
let currentExecutionTry = '';
|
||||||
let lastExecutionTry = '';
|
let lastExecutionTry = '';
|
||||||
let closeFunction: Promise<void> | undefined;
|
let closeFunction: Promise<void> | undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user