diff --git a/packages/cli/src/WorkflowExecuteAdditionalData.ts b/packages/cli/src/WorkflowExecuteAdditionalData.ts index 9a52e72052..ca1a396968 100644 --- a/packages/cli/src/WorkflowExecuteAdditionalData.ts +++ b/packages/cli/src/WorkflowExecuteAdditionalData.ts @@ -625,6 +625,21 @@ function hookFunctionsSaveWorker(): IWorkflowExecuteHooks { // send tracking and event log events, but don't wait for them void internalHooks.onWorkflowPostExecute(this.executionId, this.workflowData, fullRunData); }, + async function (this: WorkflowHooks, fullRunData: IRun, newStaticData: IDataObject) { + const externalHooks = Container.get(ExternalHooks); + if (externalHooks.exists('workflow.postExecute')) { + try { + await externalHooks.run('workflow.postExecute', [ + fullRunData, + this.workflowData, + this.executionId, + ]); + } catch (error) { + ErrorReporter.error(error); + console.error('There was a problem running hook "workflow.postExecute"', error); + } + } + }, ], nodeFetchedData: [ async (workflowId: string, node: INode) => { @@ -1014,6 +1029,7 @@ export function getWorkflowHooksWorkerExecuter( } hookFunctions[key]!.push.apply(hookFunctions[key], preExecuteFunctions[key]); } + return new WorkflowHooks(hookFunctions, mode, executionId, workflowData, optionalParameters); } diff --git a/packages/cli/src/WorkflowRunner.ts b/packages/cli/src/WorkflowRunner.ts index 995033805e..e839333968 100644 --- a/packages/cli/src/WorkflowRunner.ts +++ b/packages/cli/src/WorkflowRunner.ts @@ -217,7 +217,11 @@ export class WorkflowRunner { // only run these when not in queue mode or when the execution is manual, // since these calls are now done by the worker directly - if (executionsMode !== 'queue' || data.executionMode === 'manual') { + if ( + executionsMode !== 'queue' || + config.getEnv('generic.instanceType') === 'worker' || + data.executionMode === 'manual' + ) { const postExecutePromise = this.activeExecutions.getPostExecutePromise(executionId); const externalHooks = Container.get(ExternalHooks); postExecutePromise