fix(core): Align saving behavior in workflowExecuteAfter hooks (#12731)
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
Benchmark Docker Image CI / build (push) Waiting to run

This commit is contained in:
Iván Ovejero 2025-01-20 21:53:04 +01:00 committed by GitHub
parent 202da76380
commit 9d76210a57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 1 deletions

View file

@ -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, {}]);

View file

@ -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,