Skip to content

[Bug]: Subgraph: Error: outputSlot is undefined when output is attached to any non-zero slot #4257

Open
@rgthree

Description

@rgthree

Custom Node Testing

Frontend Version

ComfyUI_frontend v1.22.2-sub.10

Expected Behavior

Subgraph executes correctly.

Actual Behavior

An error is thrown (shown in toast): outputSlot is undefined

Steps to Reproduce

In a subgraph, have a node with more than 1 outputs connect its 1+ index'ed output to the subgraph output.

Here's a simple, non-custom example. Notice how it's the LoadImage's second output (MASK) that is connected.:

Image

FWIW, here's a real-world example, where the user wants to export the image and the seed from the subgraph, each in an rgthree-custom Context node and, both, the 7th & 8th output index:

Image

Debug Logs

N/A

Browser Logs

N/A

Setting JSON

N/A

What browsers do you use to access the UI ?

No response

Other Information

If you consider the workflow, we should see the tensor mask data in the display any:

Image

So the problem lies here, it seems:

let link = node.getInputLink(i)
while (
parent?.mode === LGraphEventMode.BYPASS ||
parent?.isVirtualNode
) {
if (!link) break
if (parent.isVirtualNode) {
link = parent.getInputLink(link.origin_slot)
if (!link) break
parent = parent.isSubgraphNode()
? parent.resolveSubgraphOutputLink(link.origin_slot)?.outputNode
: parent.getInputNode(link.target_slot)

What happens in the code, is the following:

  • When evaluating the DisplayAny output node the link set on line 126 is from DisplayAny.input[0] -> SubGraph.output[0] with the link.origin_slot being 0.
  • We then get into line 133 because the parent is the Subgraph connected to the DisplayAny node.
  • And on line 134 link is reevaluate and set to the Subgraph parent input link for slot 0 which inside the subgraph which, in this example, is the LoadImage,output[1] where the new link's origin_slot is now 1 (that's important)
  • Then, on line 138, this new link.origin_slot of 1 is sent to the parent.resolveSubgraphOutputLink which fails because there is no "slot 1" of the Subgraph output.

┆Issue is synchronized with this Notion page by Unito

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions