Sign In

Patch for the ComfyUI Frontend

0

Dec 6, 2025

(Updated: 21 hours ago)

resource guide
Patch for the ComfyUI Frontend

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 = 0 before scan so forEachNode recalculates 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$1 to patchSerialisedLinks (null-safe ??[])
    and add patchPromotedWidgets call for promoted widget remapping.

Fix 2 — remapNodeIds (load path)

  • Replaced findNextAvailableId with compact sequential scan from c=1.
    IDs are assigned 1, 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 (not n) to remapNodeIds so 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.lastNodeId around super.configure().
    Prevents the LiteGraph base configure from writing subgraph-internal node
    IDs back into the root graph counter.


How to Apply

  1. Copy api-Bo77DmmK.js from 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/
  1. 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 release

  • The 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_id inflates 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:

  1. Always remap with recalculated counterremapClipboardSubgraphNodeIds now resets
    lastNodeId to 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 via nextUniqueNodeId() — 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):

  1. Compact remapNodeIds — the load-path remapNodeIds function was rewritten to always
    assign compact sequential IDs starting from 1 (skipping IDs already occupied by root
    nodes via a Set). All subgraph-internal nodes are remapped so patchSerialisedLinks
    and patchPromotedWidgets can update all references correctly. The old
    findNextAvailableId helper was removed entirely.

  2. Dedup local statededuplicateSubgraphNodeIds now passes a local counter copy
    {lastNodeId: n.lastNodeId} to remapNodeIds instead of n directly, so any
    increments during conflict resolution never write back to rootGraph.state.lastNodeId.

  3. Subgraph.configure guard — saves and restores rootGraph.state.lastNodeId around
    super.configure() inside Subgraph.configure(), blocking the addNode and Math.max
    paths that would otherwise bump the root counter as each subgraph node is registered.


How to Apply

  1. Copy api-yYmjF75S.js from 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/
  1. 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 release

  • The 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

0