Skip to content

Commit

Permalink
fix(core): Retry before continue on fail (n8n-io#9395)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivov authored May 17, 2024
1 parent 8069faa commit 9b2ce81
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion packages/core/src/WorkflowExecute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
NodeConnectionType,
ApplicationError,
NodeExecutionOutput,
sleep,
} from 'n8n-workflow';
import get from 'lodash/get';
import * as NodeExecuteFunctions from './NodeExecuteFunctions';
Expand Down Expand Up @@ -1054,7 +1055,7 @@ export class WorkflowExecute {
workflowId: workflow.id,
});

const runNodeData = await workflow.runNode(
let runNodeData = await workflow.runNode(
executionData,
this.runExecutionData,
runIndex,
Expand All @@ -1066,6 +1067,24 @@ export class WorkflowExecute {

nodeSuccessData = runNodeData.data;

const didContinueOnFail = nodeSuccessData?.at(0)?.at(0)?.json.error !== undefined;

while (didContinueOnFail && tryIndex !== maxTries - 1) {
await sleep(waitBetweenTries);

runNodeData = await workflow.runNode(
executionData,
this.runExecutionData,
runIndex,
this.additionalData,
NodeExecuteFunctions,
this.mode,
this.abortController.signal,
);

tryIndex++;
}

if (nodeSuccessData instanceof NodeExecutionOutput) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
const hints: NodeExecutionHint[] = nodeSuccessData.getHints();
Expand Down

0 comments on commit 9b2ce81

Please sign in to comment.