Trung0246 / ComfyUI-0246

Random nodes for ComfyUI
MIT License
108 stars 11 forks source link

Errror occurs when highway nodes are present #20

Closed Pojo267 closed 8 months ago

Pojo267 commented 8 months ago

This error occurs when I try to run a workflow that includes highway nodes. It functions properly again as soon as they are removed.

Traceback (most recent call last):
  File "C:\Users\[Username]\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "C:\Users\[Username]\AppData\Local\Programs\Python\Python310\lib\threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\[Username]\OneDrive\Documents\GitHub\[ProjectName]\main.py", line 111, in prompt_worker
    e.execute(item[2], prompt_id, item[3], item[4])
  File "C:\Users\[Username]\OneDrive\Documents\GitHub\[ProjectName]\custom_nodes\rgthree-comfy\__init__.py", line 173, in rgthree_execute
    return self.old_execute(*args, **kwargs)
  File "C:\Users\[Username]\OneDrive\Documents\GitHub\[ProjectName]\custom_nodes\ComfyUI-0246\utils.py", line 362, in new_func
    res_value = old_func(*final_args, **kwargs)
  File "C:\Users\[Username]\OneDrive\Documents\GitHub\[ProjectName]\execution.py", line 375, in execute
    to_execute = sorted(list(map(lambda a: (len(recursive_will_execute(prompt, self.outputs, a[-1])), a[-1]), to_execute)))
  File "C:\Users\[Username]\OneDrive\Documents\GitHub\[ProjectName]\execution.py", line 375, in <lambda>
    to_execute = sorted(list(map(lambda a: (len(recursive_will_execute(prompt, self.outputs, a[-1])), a[-1]), to_execute)))
OverflowError: cannot fit 'int' into an index-sized integer

There is mention of rgthree in the error so I'm not sure if there's perhaps some kind of conflict.

Trung0246 commented 8 months ago

Can you share the buggy workflow? This sounds like a conflict for sure.

Pojo267 commented 8 months ago

Can you share the buggy workflow? This sounds like a conflict for sure.

Sure thing CharacterConsistencyRandomizer.json

Trung0246 commented 8 months ago

Quick question: did you use https://github.com/PCMonsterx/ComfyUI-CSV-Loader or https://github.com/theUpsider/ComfyUI-Styles_CSV_Loader for Load Styles CSV since both of these are conflict nodes.

Edit: nvm it looks the second one. Gotta debug this now.

Trung0246 commented 8 months ago

After debugging, something is very wrong with how rgthree patching the execution mechanism. The main problem is this:

image

This value is too large, which cause the following to crash:

image

The problematic node is 634. Trying to figure out how did the node cause such huge count. I've probably open another issue on rgthree side.

Will temporary close this issue for now since it looks more like rgthree side is the root cause.

image

More potential problematic nodes if you wants to fix the workflow: 629, 626, 631

Trung0246 commented 8 months ago

Here's the current temp fix I found so far:

def sort_key(a):
    result = recursive_will_execute(prompt, self.outputs, a[-1])
    result_len = 0
    try:
        result_len = len(result)
    except Exception as ex:
        result_len = result.count
    return result_len, a[-1]

while len(to_execute) > 0:
    #always execute the output that depends on the least amount of unexecuted nodes first
    # to_execute = sorted(list(map(lambda a: (len(recursive_will_execute(prompt, self.outputs, a[-1])), a[-1]), to_execute)))
    to_execute = sorted(to_execute, key=sort_key)
    output_node_id = to_execute.pop(0)[-1]

    # This call shouldn't raise anything if there's an error deep in
    # the actual SD code, instead it will report the node where the
    # error was raised
    success, error, ex = recursive_execute(self.server, prompt, self.outputs, output_node_id, extra_data, executed, prompt_id, self.outputs_ui, self.object_storage)
    if success is not True:
        self.handle_execution_error(prompt_id, prompt, current_outputs, executed, error, ex)

Put that code within this line. Make sure that the old while loop should be removed:

https://github.com/comfyanonymous/ComfyUI/blob/f9e55d8463da692954d84f51ca354161396fe1b8/execution.py#L381

Unsure if this works at all since I need a Face Image Directory and currently lazy to set that up and attempting to understand the workflow.

rgthree commented 8 months ago

Thanks, I've added a comment in https://github.com/rgthree/rgthree-comfy/issues/118 for @Pojo267 (who I don't think is tagged there because they aren't yet a participant, so tagging here).