mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-27 04:12:38 -08:00
fix(core): Ensure execution deletion in worker lifecycle hook (#7481)
Reported by customer [here](https://n8nio.slack.com/archives/C05PUALKZHD/p1697446945481249?thread_ts=1697196557.638169&cid=C05PUALKZHD), apparently a very old long-standing bug for queue mode. Please review closely as I am not familiar with queue mode.
This commit is contained in:
parent
05586a900d
commit
742c8a8534
|
@ -1129,6 +1129,36 @@ export function getWorkflowHooksWorkerMain(
|
||||||
// So to avoid confusion, we are removing other hooks.
|
// So to avoid confusion, we are removing other hooks.
|
||||||
hookFunctions.nodeExecuteBefore = [];
|
hookFunctions.nodeExecuteBefore = [];
|
||||||
hookFunctions.nodeExecuteAfter = [];
|
hookFunctions.nodeExecuteAfter = [];
|
||||||
|
hookFunctions.workflowExecuteAfter = [
|
||||||
|
async function (
|
||||||
|
this: WorkflowHooks,
|
||||||
|
fullRunData: IRun,
|
||||||
|
newStaticData: IDataObject,
|
||||||
|
): Promise<void> {
|
||||||
|
// Check config to know if execution should be saved or not
|
||||||
|
let saveDataErrorExecution = config.getEnv('executions.saveDataOnError') as string;
|
||||||
|
let saveDataSuccessExecution = config.getEnv('executions.saveDataOnSuccess') as string;
|
||||||
|
if (this.workflowData.settings !== undefined) {
|
||||||
|
saveDataErrorExecution =
|
||||||
|
(this.workflowData.settings.saveDataErrorExecution as string) || saveDataErrorExecution;
|
||||||
|
saveDataSuccessExecution =
|
||||||
|
(this.workflowData.settings.saveDataSuccessExecution as string) ||
|
||||||
|
saveDataSuccessExecution;
|
||||||
|
}
|
||||||
|
|
||||||
|
const workflowStatusFinal = determineFinalExecutionStatus(fullRunData);
|
||||||
|
|
||||||
|
if (
|
||||||
|
(workflowStatusFinal === 'success' && saveDataSuccessExecution === 'none') ||
|
||||||
|
(workflowStatusFinal !== 'success' && saveDataErrorExecution === 'none')
|
||||||
|
) {
|
||||||
|
await Container.get(ExecutionRepository).hardDelete({
|
||||||
|
workflowId: this.workflowData.id as string,
|
||||||
|
executionId: this.executionId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
return new WorkflowHooks(hookFunctions, mode, executionId, workflowData, optionalParameters);
|
return new WorkflowHooks(hookFunctions, mode, executionId, workflowData, optionalParameters);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue