Comfy-Org / Comfy-Org/ComfyUI

Template with a node with forceInput='true' breaks ComfyUI

Open
#2,766 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
133k
Forks
15.7k
Avg merge
1d 7h
Merged PRs (30d)
158

Description

# Steps to reproduce:

- clean ComfyUI install
- add a trivial node with forceInput=True
```python
class IntToInt:
@classmethod
def INPUT_TYPES(cls):
return {"required": { "int": ( "INT", { "default": 0, "forceInput": True, }, ), } }

RETURN_TYPES = ("INT",)
FUNCTION = "int_to_int"
CATEGORY = "test"

def int_to_int(self, int):
return (int,)

NODE_CLASS_MAPPINGS = { "int to int" : IntToInt }
```
- add this node and a primitive
![Screenshot 2024-02-12 083946](https://github.com/comfyanonymous/ComfyUI/assets/4371971/38ed3072-2636-46a5-be43-70345c69ef21)
- Press 'Queue Prompt'
- Correct error message ("Prompt has no outputs") seen
- Select the two nodes and save them as a template
- Delete the two nodes
- Add them back as a template
- Press `Queue Prompt`
- No error message appears
- JS console shows infinite call stack
![Screenshot 2024-02-12 084033](https://github.com/comfyanonymous/ComfyUI/assets/4371971/a2757331-4d19-437f-a3f1-54827f0334ff)

# Diagnosis

When a template is added with a `forceInput`, `hideWidget` is called twice:

![Screenshot 2024-02-12 082235](https://github.com/comfyanonymous/ComfyUI/assets/4371971/a0a122eb-7b67-4d2f-8316-c3b14a177aa9)
![Screenshot 2024-02-12 082242](https://github.com/comfyanonymous/ComfyUI/assets/4371971/9a4dc2d1-f42d-4081-a4c3-f99593a47f6a)
This causes `serializeValue` to be replaced twice; the second time it is called `origSerializeValue` already points to the new `serializeValue`.

# Fix

Check if a widget has already been hidden at the start of `hideWidget` by inserting:

```javascript
function hideWidget(node, widget, suffix = "") {
if (widget.type?.startsWith(CONVERTED_TYPE) return;
```

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.