Warn users if calling connectSlots incorrectly (#724)

Prevents silent failures from going unnoticed.
This commit is contained in:
filtered
2025-03-09 05:21:10 +11:00
committed by GitHub
parent 68945cb54d
commit 5ab9d9d25c

View File

@@ -417,6 +417,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
value: unknown, value: unknown,
prev_value?: unknown, prev_value?: unknown,
): boolean ): boolean
/** Called for each connection that is created, updated, or removed. This includes "restored" connections when deserialising. */
onConnectionsChange?( onConnectionsChange?(
this: LGraphNode, this: LGraphNode,
type: ISlotType, type: ISlotType,
@@ -2456,9 +2457,15 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
if (!graph) throw new NullGraphError() if (!graph) throw new NullGraphError()
const outputIndex = this.outputs.indexOf(output) const outputIndex = this.outputs.indexOf(output)
if (outputIndex === -1) return if (outputIndex === -1) {
console.warn("connectSlots: output not found")
return
}
const inputIndex = inputNode.inputs.indexOf(input) const inputIndex = inputNode.inputs.indexOf(input)
if (inputIndex === -1) return if (inputIndex === -1) {
console.warn("connectSlots: input not found")
return
}
// check targetSlot and check connection types // check targetSlot and check connection types
if (!LiteGraph.isValidConnection(output.type, input.type)) { if (!LiteGraph.isValidConnection(output.type, input.type)) {