diff --git a/packages/cli/src/__tests__/execution-lifecycle-hooks.test.ts b/packages/cli/src/__tests__/execution-lifecycle-hooks.test.ts index 331d51e97e..8138c10f07 100644 --- a/packages/cli/src/__tests__/execution-lifecycle-hooks.test.ts +++ b/packages/cli/src/__tests__/execution-lifecycle-hooks.test.ts @@ -500,6 +500,10 @@ describe('Execution Lifecycle Hooks', () => { saveDataSuccessExecution: 'none', saveDataErrorExecution: 'all', }; + const hooks = getWorkflowHooksWorkerMain('webhook', executionId, workflowData, { + pushRef, + retryOf, + }); await hooks.executeHookFunctions('workflowExecuteAfter', [successfulRun, {}]); @@ -514,6 +518,10 @@ describe('Execution Lifecycle Hooks', () => { saveDataSuccessExecution: 'all', saveDataErrorExecution: 'none', }; + const hooks = getWorkflowHooksWorkerMain('webhook', executionId, workflowData, { + pushRef, + retryOf, + }); await hooks.executeHookFunctions('workflowExecuteAfter', [failedRun, {}]); diff --git a/packages/cli/src/workflow-execute-additional-data.ts b/packages/cli/src/workflow-execute-additional-data.ts index f559765ec3..ac1199ba3c 100644 --- a/packages/cli/src/workflow-execute-additional-data.ts +++ b/packages/cli/src/workflow-execute-additional-data.ts @@ -1150,11 +1150,28 @@ export function getWorkflowHooksWorkerMain( const saveSettings = toSaveSettings(this.workflowData.settings); + const isManualMode = this.mode === 'manual'; + + if (isManualMode && !saveSettings.manual && !fullRunData.waitTill) { + /** + * When manual executions are not being saved, we only soft-delete + * the execution so that the user can access its binary data + * while building their workflow. + * + * The manual execution and its binary data will be hard-deleted + * on the next pruning cycle after the grace period set by + * `EXECUTIONS_DATA_HARD_DELETE_BUFFER`. + */ + await Container.get(ExecutionRepository).softDelete(this.executionId); + + return; + } + const shouldNotSave = (executionStatus === 'success' && !saveSettings.success) || (executionStatus !== 'success' && !saveSettings.error); - if (shouldNotSave) { + if (!isManualMode && shouldNotSave && !fullRunData.waitTill) { await Container.get(ExecutionRepository).hardDelete({ workflowId: this.workflowData.id, executionId: this.executionId,