Comfy-Org / Comfy-Org/ComfyUI_frontend

Nodes 2.0 breaks custom node replacement mapping that works correctly in LiteGraph mode

Open
#10,988 2 comments 0 reactions 1 assignee Claimed by @christian-byrne View on GitHub
area:nodes area:ui area:vue-migration in review pick:tier-3 Potential Bug
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

### Prerequisites

- [x] I am running the latest version of ComfyUI
- [x] I have custom nodes enabled

### What happened?

### Checklist

- [x] I searched existing issues
- [x] This reproduces in the current frontend
- [x] The same workflow works correctly in LiteGraph mode

### Summary

Custom node replacement works correctly in the old LiteGraph renderer, but breaks in `Nodes 2.0`.

With `Nodes 2.0` enabled, the replacement UI appears and the node is replaced, but:
- renamed widget values are not transferred correctly
- some widget values become wrong defaults (`exposure` becomes `0`) or not using the current value
- output port colors are wrong
- output connections are attached to the wrong ports

If I disable `Nodes 2.0` and use the old LiteGraph renderer, the exact same workflow and replacement mapping display correctly immediately, with no other changes.

This strongly suggests the backend replacement and workflow data are correct, and the bug is in the `Nodes 2.0` frontend path.

### Environment

- ComfyUI: `0.18.1`
- Frontend package: `1.42.8`
- Install type: Windows portable
- OS: Windows 11
- Renderer modes tested:
- `Nodes 2.0`: broken
- old LiteGraph mode: correct

### Reproduction

I created a custom node replacement test with these two nodes:

#### Old node
Node id: `DummyImageInputProbeV3MA`

Inputs:
1. `image`
2. `mask` (optional)
3. `gain`
4. `apply_mask`
5. `label`

Outputs:
1. `output_image`
2. `resolved_mask`
3. `info`
4. `width`
5. `height`
6. `image_mean`

#### New node
Node id: `DummyImageProbeAdvNewMA`

Inputs:
1. `annotation`
2. `exposure`
3. `image`
4. `mask`

Outputs:
1. `image_mean`
2. `resolved_mask`
3. `output_image`
4. `info`
5. `width`
6. `height`

#### Replacement mapping

```python
io.NodeReplace(
new_node_id="DummyImageProbeAdvNewMA",
old_node_id="DummyImageInputProbeV3MA",
old_widget_ids=["gain", "apply_mask", "label"],
input_mapping=[
{"new_id": "annotation", "old_id": "label"},
{"new_id": "exposure", "old_id": "gain"},
{"new_id": "image", "old_id": "image"},
{"new_id": "mask", "old_id": "mask"},
],
output_mapping=[
{"new_idx": 0, "old_idx": 5},
{"new_idx": 1, "old_idx": 1},
{"new_idx": 2, "old_idx": 0},
{"new_idx": 3, "old_idx": 2},
{"new_idx": 4, "old_idx": 3},
{"new_idx": 5, "old_idx": 4},
],
)

### Steps to Reproduce

1. Enable node replacement suggestions in ComfyUI Settings (which should be mentioned in the docs about Node Replacement)
2. Enable Nodes 2.0
3. Load a workflow containing the missing old node DummyImageInputProbeV3MA
4. Use the replacement UI to replace it with DummyImageProbeAdvNewMA
5. Observe bad widget values, port colors, and connections
6. Disable Nodes 2.0
7. Reopen the same workflow / view the same replaced graph in LiteGraph mode

**Expected behavior:**
After replacement, the new node should have:

Input/widget mapping:
gain -> exposure
label -> annotation
image -> image
mask -> mask
apply_mask dropped

Output mapping:
output_image -> output_image
resolved_mask -> resolved_mask
info -> info
width -> width
height -> height
image_mean -> image_mean

This is exactly what I see in LiteGraph mode.

**Actual behavior in Nodes 2.0:**

annotation becomes empty instead of getting the old label value
exposure becomes 0 instead of getting the old gain value
output port colors are incorrect
connections are attached to different/wrong output ports

Important observation:
If I turn off Nodes 2.0, the replaced workflow immediately looks correct in LiteGraph mode.

### How is this affecting you?

Visual/UI issue only

### ComfyUI Frontend Version

1.42.8

### Browser

Chrome/Chromium

### Console Errors

```javascript

```

### Logs

```shell

```

### Additional Context

_No response_

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-10988-Nodes-2-0-breaks-custom-node-replacement-mapping-that-works-correctly-in-LiteGraph-mo-33d6d73d365081c5a5d2cfb9e60093b6) 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.