From 7da86641d5231fe8d384b8372d7e2dc4ea15b6d4 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Thu, 19 Aug 2021 18:29:20 +0200 Subject: [PATCH] :bug: Fix issue with referencing values before loops --- packages/workflow/src/Workflow.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/workflow/src/Workflow.ts b/packages/workflow/src/Workflow.ts index fb4189d762..57fbe25625 100644 --- a/packages/workflow/src/Workflow.ts +++ b/packages/workflow/src/Workflow.ts @@ -635,6 +635,17 @@ export class Workflow { * @memberof Workflow */ getNodeConnectionOutputIndex(nodeName: string, parentNodeName: string, type = 'main', depth = -1, checkedNodes?: string[]): number | undefined { + const node = this.getNode(parentNodeName); + if (node === null) { + return undefined; + } + const nodeType = this.nodeTypes.getByName(node.type) as INodeType; + if (nodeType.description.outputs.length === 1) { + // If the parent node has only one output, it can only be connected + // to that one. So no further checking is required. + return 0; + } + depth = depth === -1 ? -1 : depth; const newDepth = depth === -1 ? depth : depth - 1; if (depth === 0) { @@ -669,8 +680,8 @@ export class Workflow { } if (checkedNodes!.includes(connection.node)) { - // Node got checked already before - return; + // Node got checked already before so continue with the next one + continue; } outputIndex = this.getNodeConnectionOutputIndex(connection.node, parentNodeName, type, newDepth, checkedNodes);