Skip to content

Commit

Permalink
fix(core): So not execute workflowExecuteBefore hook when resuming …
Browse files Browse the repository at this point in the history
…executions from a waiting state
  • Loading branch information
netroy committed Apr 5, 2023
1 parent dba5be3 commit 3f72afe
Show file tree
Hide file tree
Showing 5 changed files with 10 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
5 changes: 4 additions & 1 deletion packages/core/src/WorkflowExecute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,10 @@ export class WorkflowExecute {

const returnPromise = (async () => {
try {
await this.executeHook('workflowExecuteBefore', [workflow]);
const { executionId, restartExecutionId } = this.additionalData;
if (restartExecutionId !== executionId) {
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 3f72afe

Please sign in to comment.