From 9b2ce819d42c4a541ae94956aaab608a989ec588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Fri, 17 May 2024 10:46:42 +0200 Subject: [PATCH] fix(core): Retry before continue on fail (#9395) --- packages/core/src/WorkflowExecute.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/core/src/WorkflowExecute.ts b/packages/core/src/WorkflowExecute.ts index a87f98b25d29f..c518eb2c1be36 100644 --- a/packages/core/src/WorkflowExecute.ts +++ b/packages/core/src/WorkflowExecute.ts @@ -43,6 +43,7 @@ import { NodeConnectionType, ApplicationError, NodeExecutionOutput, + sleep, } from 'n8n-workflow'; import get from 'lodash/get'; import * as NodeExecuteFunctions from './NodeExecuteFunctions'; @@ -1054,7 +1055,7 @@ export class WorkflowExecute { workflowId: workflow.id, }); - const runNodeData = await workflow.runNode( + let runNodeData = await workflow.runNode( executionData, this.runExecutionData, runIndex, @@ -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();