Comfy-Org / Comfy-Org/ComfyUI_frontend

loadApiJson resolves inputs twice, firing duplicate onConnectionsChange events

Open
#14,654 2 comments 1 reaction 0 assignees View on GitHub
area:nodes perf:speed Potential Bug Public API
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

`ComfyApp.loadApiJson` resolves links by running the same loop twice:

```js
for (const id of ids) processNodeInputs(id)
app.rootGraph.arrange()
for (const id of ids) processNodeInputs(id)
app.rootGraph.arrange()
```

On the second pass every input that the first pass already connected is disconnected and reconnected with a new link id, so `onConnectionsChange` fires twice per input slot for a single load. `arrange()` also runs twice.

The final serialized state is correct, so this is not a data bug. It is wasted work and duplicate callback traffic on a callback that the custom-node ecosystem hooks (per AGENTS.md, `onConnectionsChange` changes affect 40+ custom node repos).

Pre-existing — the double loop predates #14555. Raised by @christian-byrne there because placeholder nodes for uninstalled types now participate in it, which makes the duplicate events more visible.

**Suggested investigation:** find out what the second pass was for. If it exists to handle inputs that only become connectable after a later node is added, a single pass ordered by dependency, or a deferred pass over just the unresolved inputs, would do the same job without re-wiring what already succeeded.

Contributor guide

Open the contributing guide

Research direction

Start at the ComfyApp.loadApiJson entry point and inspect the two processNodeInputs loops and arrange() calls. Read AGENTS.md for the callback compatibility context, then determine why the second pass exists and how unresolved inputs are handled. Done means preserving correct serialized state without rewiring successful inputs or firing duplicate onConnectionsChange events.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.