Skip to content

Commit

Permalink
fix(core): Do not execute workflowExecuteBefore hook when resuming …
Browse files Browse the repository at this point in the history
…executions from a waiting state (#5727)
  • Loading branch information
netroy authored Apr 6, 2023
1 parent b1e1c5b commit 6689451
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/cli/src/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ export interface IProcessMessageDataHook {

export interface IWorkflowExecutionDataProcess {
destinationNode?: string;
restartExecutionId?: string;
executionMode: WorkflowExecuteMode;
executionData?: IRunExecutionData;
runData?: IRunData;
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/WorkflowRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ export class WorkflowRunner {
undefined,
workflowTimeout <= 0 ? undefined : Date.now() + workflowTimeout * 1000,
);
additionalData.restartExecutionId = restartExecutionId;

// Register the active execution
const executionId = await this.activeExecutions.add(data, undefined, restartExecutionId);
Expand Down Expand Up @@ -644,6 +645,8 @@ export class WorkflowRunner {
data.workflowData.staticData = await WorkflowHelpers.getStaticDataById(workflowId);
}

data.restartExecutionId = restartExecutionId;

// Register the active execution
const executionId = await this.activeExecutions.add(data, subprocess, restartExecutionId);

Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/WorkflowRunnerProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ class WorkflowRunnerProcess {
undefined,
workflowTimeout <= 0 ? undefined : Date.now() + workflowTimeout * 1000,
);
additionalData.restartExecutionId = this.data.restartExecutionId;
additionalData.hooks = this.getProcessForwardHooks();

additionalData.hooks.hookFunctions.sendResponse = [
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/WorkflowExecute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,9 @@ export class WorkflowExecute {

const returnPromise = (async () => {
try {
await this.executeHook('workflowExecuteBefore', [workflow]);
if (!this.additionalData.restartExecutionId) {
await this.executeHook('workflowExecuteBefore', [workflow]);
}
} catch (error) {
// Set the error that it can be saved correctly
executionError = {
Expand Down
1 change: 1 addition & 0 deletions packages/workflow/src/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1677,6 +1677,7 @@ export interface IWorkflowExecuteAdditionalData {
) => Promise<any>;
// hooks?: IWorkflowExecuteHooks;
executionId?: string;
restartExecutionId?: string;
hooks?: WorkflowHooks;
httpResponse?: express.Response;
httpRequest?: express.Request;
Expand Down

0 comments on commit 6689451

Please sign in to comment.