Repository navigation
fix(node-fixer): reconnect inputs to the new node, not its id (#3126) - #3402
Open
StevenLi-phoenix wants to merge 1 commit into
Open
StevenLi-phoenix wants to merge 1 commit into
StevenLi-phoenix wants to merge 1 commit into
Conversation
…Org#3126) "Fix node (recreate)" passed dest.id to LGraphNode.connect() when it re-wired each linked input. Node ids are strings on current frontends, and connect() only looks a target up by id when it is a number, so it called findInputSlot() on the id string and threw. The replacement node had already been added, so the original was never removed and the canvas kept both. Pass the node itself, as the output loop already does. Fixes Comfy-Org#3126. Co-authored-by: Claude Opus-5-5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3126
The root cause and the one-argument fix are as @EnragedAntelope diagnosed in the issue.
Problem
On current frontends, "Fix node (recreate)" fails on any node that has a connected input. The console shows
TypeError: t.findInputSlot is not a function, and the canvas keeps two copies of the node: the original, still wired, and an unwired replacement.Root cause
node_info_copy()injs/node_fixer.jsre-wired each linked input with:NodeIdis a string on current frontends.LGraphNode.connect()looks up the target by id only whentypeof target_node === 'number'. Any other value is used as the node itself, so the id string got totarget_node.findInputSlot(...)and threw. The menu callback adds the replacement node before it callsnode_info_copy(), so the throw skippedapp.canvas.graph.remove(this)and both nodes stayed on the canvas.Fix
Pass the node instead of its id, as the output loop in the same function already does (
dest.connect(parseInt(i), target_node, link.target_slot)). This is a one-line change.I did not take the issue's second suggestion, to remove the original before re-wiring.
LGraph.remove()disconnects the node's inputs and outputs, and those are the linksnode_info_copy()reads.Tests
tests/test_node_fixer_recreate.pylifts the shippednode_info_copy()and the menu callback withtests/js_lift.py. It runs them in node against a small stub graph that has string node ids and the sameconnect()id-resolution rule as litegraph. It covers:node_info_copy()re-creates the input link and the output link on the new node.Red, against the pre-fix file:
Green, and the rest of the suite:
I did not run
tests/e2e. It needs the separate E2E ComfyUI root, and it does not covernode_fixer.js.Manual check: ComfyUI master (46aad33) with
comfyui-frontend-package==1.57.1,python main.py --cpu, and headless Chromium.node_fixer.jswas loaded as a web extension. I wired CheckpointLoaderSimple -> KSampler -> VAEDecode. Then I called the KSampler's "Fix node (recreate)" entry fromgetExtraMenuOptions()in the page.TypeError: t.findInputSlot is not a function. Nodes 1, 2, 3, 4, with KSampler twice. The links still pointed to the original node 2.Not covered
Recreating a node inside a subgraph still fails, with a different cause.
node_info_copy()reads links fromapp.graph(the root graph), so it cannot find links that are inside the subgraph. On 1.57.1 it throwsCannot read properties of undefined (reading 'origin_id'). Inputs that come from the subgraph's input node would need their own handling as well, so I left this for a separate change.The same
dest.idline is also incomfyui_manager/js/node_fixer.jsonmanager-v4.