mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
do not even setup the nodeExecuteAfter
hook for progress saving if the settings disable progress saving
This commit is contained in:
parent
4471c0f066
commit
50b45cff3a
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<void> {
|
||||
await saveExecutionProgress(
|
||||
saveSettings,
|
||||
this.workflowData.id,
|
||||
this.executionId,
|
||||
nodeName,
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue