From 01e4260d4c6dc1f823b4e5fe57aae8db071b8f30 Mon Sep 17 00:00:00 2001 From: Benjamin Lu Date: Tue, 5 Aug 2025 18:28:07 -0400 Subject: [PATCH] Fix duplicated inputs on loading nested subgraphs Subgraphs are loaded in order of creation. Under most circumstances, this means newer subgraphs are loaded first. With nested subgraphs, this means a subgraph node has it's inputs connected before it's inside is loaded. When the inner subgraph is loaded, input-added events are triggered even though inputs already exist on the subgraph node. This is resolved by adding a check for if an input of the corresponding name already exists when adding an input. Port of https://github.com/Comfy-Org/litegraph.js/pull/1192 --- src/lib/litegraph/src/subgraph/SubgraphNode.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/litegraph/src/subgraph/SubgraphNode.ts b/src/lib/litegraph/src/subgraph/SubgraphNode.ts index 846d40a67..6644fcf51 100644 --- a/src/lib/litegraph/src/subgraph/SubgraphNode.ts +++ b/src/lib/litegraph/src/subgraph/SubgraphNode.ts @@ -72,6 +72,7 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph { (e) => { const subgraphInput = e.detail.input const { name, type } = subgraphInput + if (this.inputs.some((i) => i.name == name)) return const input = this.addInput(name, type) this.#addSubgraphInputListeners(subgraphInput, input)