Files
ComfyUI_frontend/src/utils/executableGroupNodeDto.ts
Christian Byrne f5363e4028 fix: return undefined for muted node output resolution (#9302)
## Summary

Muted (NEVER mode) subgraph nodes throw "No inner node DTO found" during
prompt serialization because `resolveOutput()` falls through to subgraph
resolution for nodes whose inner DTOs were never registered.

## Changes

- **What**: Add early return in `ExecutableNodeDTO.resolveOutput()` for
`NEVER` mode nodes, matching the existing `BYPASS` mode guard. Add 5
tests covering muted, bypassed, and normal mode resolution.

## Review Focus

The fix is a single-line early return. The key insight is that
`graphToPrompt` in `executionUtil.ts` correctly skips `getInnerNodes()`
for muted/bypassed nodes, so their inner DTOs are never in the map — but
`resolveOutput()` was missing the corresponding guard for `NEVER` mode.

Fixes #8986

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-9302-fix-return-undefined-for-muted-node-output-resolution-3156d73d3650811e9697c7281f11cf96)
by [Unito](https://www.unito.io)
2026-03-12 17:44:32 -07:00

77 lines
2.2 KiB
TypeScript

import {
ExecutableNodeDTO,
LGraphEventMode
} from '@/lib/litegraph/src/litegraph'
import type {
ExecutableLGraphNode,
ISlotType,
LGraphNode
} from '@/lib/litegraph/src/litegraph'
export const GROUP = Symbol()
export function isGroupNode(node: LGraphNode): boolean {
return node.constructor?.nodeData?.[GROUP] !== undefined
}
export class ExecutableGroupNodeDTO extends ExecutableNodeDTO {
override get isVirtualNode(): true {
return true
}
override getInnerNodes(): ExecutableLGraphNode[] {
return this.node.getInnerNodes?.(this.nodesByExecutionId) ?? []
}
override resolveOutput(slot: number, type: ISlotType, visited: Set<string>) {
// Muted nodes produce no output
if (this.mode === LGraphEventMode.NEVER) return
// Temporary duplication: Bypass nodes are bypassed using the first input with matching type
if (this.mode === LGraphEventMode.BYPASS) {
const { inputs } = this
// Bypass nodes by finding first input with matching type
const parentInputIndexes = Object.keys(inputs).map(Number)
// Prioritise exact slot index
const indexes = [slot, ...parentInputIndexes]
const matchingIndex = indexes.find((i) => inputs[i]?.type === type)
// No input types match
if (matchingIndex === undefined) return
return this.resolveInput(matchingIndex, visited)
}
const linkId = this.node.outputs[slot]?.links?.at(0)
const link = this.node.graph?.getLink(linkId)
if (!link) {
throw new Error(
`Failed to get link for group node ${this.node.id} with link ${linkId}`
)
}
const updated = this.node.updateLink?.(link)
if (!updated) {
throw new Error(
`Failed to update link for group node ${this.node.id} with link ${linkId}`
)
}
const node = this.node
.getInnerNodes?.(this.nodesByExecutionId)
.find((node) => node.id === updated.origin_id)
if (!node) {
throw new Error(
`Failed to get node for group node ${this.node.id} with link ${linkId}`
)
}
return {
node,
origin_id: `${this.id}:${(updated.origin_id as string).split(':').at(-1)}`,
origin_slot: updated.origin_slot
}
}
}