ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

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

Open chrisgoringe opened this issue 1 year ago • 1 comments

Steps to reproduce:

  • clean ComfyUI install
  • add a trivial node with forceInput=True
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
  • 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

Diagnosis

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

Screenshot 2024-02-12 082235 Screenshot 2024-02-12 082242 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:

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

chrisgoringe avatar Feb 11 '24 21:02 chrisgoringe

Added PR #2767 as fix

chrisgoringe avatar Feb 11 '24 22:02 chrisgoringe