diff --git a/packages/cli/src/execution-lifecycle/__tests__/execution-lifecycle-hooks.test.ts b/packages/cli/src/execution-lifecycle/__tests__/execution-lifecycle-hooks.test.ts index a65463d42a..f3b862478f 100644 --- a/packages/cli/src/execution-lifecycle/__tests__/execution-lifecycle-hooks.test.ts +++ b/packages/cli/src/execution-lifecycle/__tests__/execution-lifecycle-hooks.test.ts @@ -206,7 +206,7 @@ describe('Execution Lifecycle Hooks', () => { const { hookFunctions } = hooks; expect(hookFunctions.nodeExecuteBefore).toHaveLength(2); - expect(hookFunctions.nodeExecuteAfter).toHaveLength(3); + expect(hookFunctions.nodeExecuteAfter).toHaveLength(2); expect(hookFunctions.workflowExecuteBefore).toHaveLength(3); expect(hookFunctions.workflowExecuteAfter).toHaveLength(5); expect(hookFunctions.nodeFetchedData).toHaveLength(1); @@ -242,6 +242,8 @@ describe('Execution Lifecycle Hooks', () => { workflowData.settings = { saveExecutionProgress: true }; hooks = createHooks(); + expect(hooks.hookFunctions.nodeExecuteAfter).toHaveLength(3); + await hooks.executeHookFunctions('nodeExecuteAfter', [ nodeName, taskData, @@ -258,6 +260,8 @@ describe('Execution Lifecycle Hooks', () => { workflowData.settings = { saveExecutionProgress: false }; hooks = createHooks(); + expect(hooks.hookFunctions.nodeExecuteAfter).toHaveLength(3); + await hooks.executeHookFunctions('nodeExecuteAfter', [ nodeName, taskData, @@ -622,7 +626,7 @@ describe('Execution Lifecycle Hooks', () => { const { hookFunctions } = hooks; expect(hookFunctions.nodeExecuteBefore).toHaveLength(2); - expect(hookFunctions.nodeExecuteAfter).toHaveLength(3); + expect(hookFunctions.nodeExecuteAfter).toHaveLength(2); expect(hookFunctions.workflowExecuteBefore).toHaveLength(2); expect(hookFunctions.workflowExecuteAfter).toHaveLength(4); expect(hookFunctions.nodeFetchedData).toHaveLength(1); @@ -719,7 +723,7 @@ describe('Execution Lifecycle Hooks', () => { const { hookFunctions } = hooks; expect(hookFunctions.nodeExecuteBefore).toHaveLength(1); - expect(hookFunctions.nodeExecuteAfter).toHaveLength(2); + expect(hookFunctions.nodeExecuteAfter).toHaveLength(1); expect(hookFunctions.workflowExecuteBefore).toHaveLength(2); expect(hookFunctions.workflowExecuteAfter).toHaveLength(4); expect(hookFunctions.nodeFetchedData).toHaveLength(1); diff --git a/packages/cli/src/execution-lifecycle/__tests__/save-execution-progress.test.ts b/packages/cli/src/execution-lifecycle/__tests__/save-execution-progress.test.ts index 75d52f3ac4..78887a4433 100644 --- a/packages/cli/src/execution-lifecycle/__tests__/save-execution-progress.test.ts +++ b/packages/cli/src/execution-lifecycle/__tests__/save-execution-progress.test.ts @@ -25,20 +25,12 @@ const commonArgs: [string, string, string, ITaskData, IRunExecutionData, string] 'some-session-id', ]; -const commonSettings = { error: true, success: true, manual: true }; - -test('should ignore if save settings say so', async () => { - await saveExecutionProgress({ ...commonSettings, progress: false }, ...commonArgs); - - expect(executionRepository.updateExistingExecution).not.toHaveBeenCalled(); -}); - test('should ignore on leftover async call', async () => { executionRepository.findSingleExecution.mockResolvedValue({ finished: true, } as IExecutionResponse); - await saveExecutionProgress({ ...commonSettings, progress: true }, ...commonArgs); + await saveExecutionProgress(...commonArgs); expect(executionRepository.updateExistingExecution).not.toHaveBeenCalled(); }); @@ -46,7 +38,7 @@ test('should ignore on leftover async call', async () => { test('should update execution when saving progress is enabled', async () => { executionRepository.findSingleExecution.mockResolvedValue({} as IExecutionResponse); - await saveExecutionProgress({ ...commonSettings, progress: true }, ...commonArgs); + await saveExecutionProgress(...commonArgs); expect(executionRepository.updateExistingExecution).toHaveBeenCalledWith('some-execution-id', { data: { @@ -72,7 +64,7 @@ test('should report error on failure', async () => { throw error; }); - await saveExecutionProgress({ ...commonSettings, progress: true }, ...commonArgs); + await saveExecutionProgress(...commonArgs); expect(executionRepository.updateExistingExecution).not.toHaveBeenCalled(); expect(errorReporter.error).toHaveBeenCalledWith(error); diff --git a/packages/cli/src/execution-lifecycle/execution-lifecycle-hooks.ts b/packages/cli/src/execution-lifecycle/execution-lifecycle-hooks.ts index 5350591fc6..012995e1f8 100644 --- a/packages/cli/src/execution-lifecycle/execution-lifecycle-hooks.ts +++ b/packages/cli/src/execution-lifecycle/execution-lifecycle-hooks.ts @@ -213,6 +213,7 @@ function hookFunctionsExternalHooks(): IWorkflowExecuteHooks { } function hookFunctionsSaveProgress(saveSettings: ExecutionSavingSettings): IWorkflowExecuteHooks { + if (!saveSettings.progress) return {}; return { nodeExecuteAfter: [ async function ( @@ -222,7 +223,6 @@ function hookFunctionsSaveProgress(saveSettings: ExecutionSavingSettings): IWork executionData: IRunExecutionData, ): Promise { await saveExecutionProgress( - saveSettings, this.workflowData.id, this.executionId, nodeName, diff --git a/packages/cli/src/execution-lifecycle/save-execution-progress.ts b/packages/cli/src/execution-lifecycle/save-execution-progress.ts index fe12cae262..eea94a5420 100644 --- a/packages/cli/src/execution-lifecycle/save-execution-progress.ts +++ b/packages/cli/src/execution-lifecycle/save-execution-progress.ts @@ -4,10 +4,7 @@ import type { IRunExecutionData, ITaskData } from 'n8n-workflow'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { type ExecutionSavingSettings } from './to-save-settings'; - export async function saveExecutionProgress( - saveSettings: ExecutionSavingSettings, workflowId: string, executionId: string, nodeName: string, @@ -15,8 +12,6 @@ export async function saveExecutionProgress( executionData: IRunExecutionData, pushRef?: string, ) { - if (!saveSettings.progress) return; - const logger = Container.get(Logger); try {