ComfyUI Frontend Patch — v1.44.19
— for comfy 0.23.0
File: api-Bo77DmmK.js
Purpose: Fix subgraph node ID inflation when pasting subgraph-containing workflows.
Problem
When pasting a workflow containing subgraph nodes, internal subgraph node IDs were
incorrectly leaking into the global lastNodeId counter. This caused subsequent
nodes to be created with IDs far above the actual max, leaving large gaps.
Root cause: remapClipboardSubgraphNodeIds only remapped subgraph nodes whose
IDs collided with existing IDs. Non-colliding high IDs (e.g. node 1502 from an old
workflow) were kept as-is and written to t.state.lastNodeId, inflating the counter.
Changes
Fix 1 — remapClipboardSubgraphNodeIds (paste path, core fix)
Reset
lastNodeId = 0before scan soforEachNoderecalculates the real
current max from all existing nodes (including subgraph-internal nodes, respecting
deletions).Unconditionally assign
nextUniqueNodeId()to every subgraph internal node
(not just collisions). Eliminates the "keep non-colliding high IDs" path entirely.Switch from
patchLinkNodeIds$1topatchSerialisedLinks(null-safe??[])
and addpatchPromotedWidgetscall for promoted widget remapping.
Fix 2 — remapNodeIds (load path)
Replaced
findNextAvailableIdwith compact sequential scan fromc=1.
IDs are assigned1, 2, 3, …skipping any already-taken IDs.
Prevents load-path ID inflation in newly loaded subgraph files.
Fix 3 — deduplicateSubgraphNodeIds (local state)
Introduce
_ls = { lastNodeId: n.lastNodeId }local copy.Pass
_ls(notn) toremapNodeIdsso the root graph counter is not
inflated by subgraph-internal IDs during deduplication.
Fix 4 — Subgraph.configure guard (load path)
Save and restore
_rootGraph.state.lastNodeIdaroundsuper.configure().
Prevents theLiteGraphbase configure from writing subgraph-internal node
IDs back into the root graph counter.
How to Apply
Copy
api-Bo77DmmK.jsfrom this folder into:
<your_comfy_env>/lib/python3.12/site-packages/comfyui_frontend_package/static/assets/
Linux example:
cp api-Bo77DmmK.js /mnt/data/AI/comfy_env/lib/python3.12/site-packages/comfyui_frontend_package/static/assets/
Hard-reload ComfyUI in the browser (
Ctrl+Shift+R)
⚠️ Important
This patch is for ComfyUI frontend v1.44.19 only
Check your installed version before applying — the file name contains a content hash
that changes with each frontend releaseThe patched file will be overwritten if you update the frontend package via pip —
you will need to re-apply the patch after any frontend update
ComfyUI Frontend Patch — v1.42.11
Fixes a bug where copy-pasting nodes jumps node IDs into the thousands (1900+)
instead of continuing sequentially from where your workflow left off.
The Problem
If your workflow contains a subgraph (a node group/module), copy-pasting any
nodes — even regular ones — causes all pasted node IDs to skip to very high numbers.
You paste 4 nodes → they become 1951, 1952, 1953, 1954
Over time your
last_node_idinflates into the thousands, even with only a
handful of actual nodes
This happens because the subgraph stores its own internal counter, and a bug in the
frontend causes that value to overwrite the root workflow counter during paste.
The Fix
With the patch applied, pasted nodes get the next clean sequential IDs:
You paste 4 nodes → they become 18, 19, 20, 21 ✓
Subgraph internal nodes are renumbered to compact sequential IDs (1, 2, 3...) as intended
Four changes are applied to the bundle:
Paste-path fix:
Always remap with recalculated counter —
remapClipboardSubgraphNodeIdsnow resetslastNodeIdto zero before scanning the current graph, so the counter reflects the actual
highest existing node ID (not the stale saved value from before deletions). Then every
subgraph internal node gets a fresh sequential ID vianextUniqueNodeId()— not just
colliding ones. The result: pasted subgraph nodes always continue cleanly from the real
current max, with no high-ID bleed-in from old workflows and no conflicts with existing nodes.
Load-path fixes (prevent subgraph IDs from bumping the root counter when opening a workflow):
Compact remapNodeIds — the load-path
remapNodeIdsfunction was rewritten to always
assign compact sequential IDs starting from 1 (skipping IDs already occupied by root
nodes via aSet). All subgraph-internal nodes are remapped sopatchSerialisedLinks
andpatchPromotedWidgetscan update all references correctly. The oldfindNextAvailableIdhelper was removed entirely.Dedup local state —
deduplicateSubgraphNodeIdsnow passes a local counter copy{lastNodeId: n.lastNodeId}toremapNodeIdsinstead ofndirectly, so any
increments during conflict resolution never write back torootGraph.state.lastNodeId.Subgraph.configure guard — saves and restores
rootGraph.state.lastNodeIdaroundsuper.configure()insideSubgraph.configure(), blocking theaddNodeandMath.max
paths that would otherwise bump the root counter as each subgraph node is registered.
How to Apply
Copy
api-yYmjF75S.jsfrom this folder into:
<your_comfy_env>/lib/python3.12/site-packages/comfyui_frontend_package/static/assets/
Linux example:
cp api-yYmjF75S.js /mnt/data/AI/comfy_env/lib/python3.12/site-packages/comfyui_frontend_package/static/assets/
Hard-reload ComfyUI in the browser (
Ctrl+Shift+R)
⚠️ Important
This patch is for ComfyUI frontend v1.42.11 only
Check your installed version before applying — the file name contains a content hash
that changes with each frontend releaseThe patched file will be overwritten if you update the frontend package via pip —
you will need to re-apply the patch after any frontend update


