Comfy-Org / Comfy-Org/ComfyUI_frontend

refactor: move SubgraphNode input pruning into _rebindInputSubgraphSlots and investigate underlying stale-input bug

Open
#10,119 0 comments 0 reactions 1 assignee Claimed by @DrJKL View on GitHub
area:subgraph developer experience
Dominant language
TypeScript
Stars
2k
Forks
704
Avg merge
1d 8h
Merged PRs (30d)
512

Description

## Follow-up from PR #10020

**Requested by:** @DrJKL
**Related PR:** https://github.com/Comfy-Org/ComfyUI_frontend/pull/10020
**Related comment:** https://github.com/Comfy-Org/ComfyUI_frontend/pull/10020#pullrequestreview-2697000000

---

### Background

PR #10020 fixed orphaned/duplicate `SubgraphNode` inputs that accumulated across serialize–load cycles. The fix prunes any `input` entries that no longer have a matching `_subgraphSlot` immediately after calling `_rebindInputSubgraphSlots()` inside `_internalConfigureAfterSlots()`.

### Issues to follow up on

1. **Refactor location of pruning logic** – The pruning filter currently sits *outside* `_rebindInputSubgraphSlots()` in `_internalConfigureAfterSlots()`. It would be more cohesive to move it *inside* `_rebindInputSubgraphSlots()`, so that the method is fully responsible for the canonical state of the inputs array after each rebind.

2. **Investigate the underlying bug** – The root cause of stale/duplicate inputs persisting after `LGraphNode.configure()` (which uses `cloneObject` and can expand arrays from serialized data) may not be fully addressed by the current pruning approach. A deeper investigation into why `_rebindInputSubgraphSlots()` leaves orphaned entries in the inputs array could reveal a more complete fix.

### Files of interest

- `src/lib/litegraph/src/subgraph/SubgraphNode.ts` – `_internalConfigureAfterSlots()` and `_rebindInputSubgraphSlots()`
- `src/lib/litegraph/src/subgraph/SubgraphNode.test.ts` – regression tests added in PR #10020

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-10119-refactor-move-SubgraphNode-input-pruning-into-_rebindInputSubgraphSlots-and-investig-3256d73d365081bc98d5f2ef3ee06aaf) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.