From 5ab9d9d25ca965bb597c613ed7c6cdcd95dc5c1e Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Sun, 9 Mar 2025 05:21:10 +1100 Subject: [PATCH] Warn users if calling connectSlots incorrectly (#724) Prevents silent failures from going unnoticed. --- src/LGraphNode.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/LGraphNode.ts b/src/LGraphNode.ts index 601b59a4c..9c01b69bf 100644 --- a/src/LGraphNode.ts +++ b/src/LGraphNode.ts @@ -417,6 +417,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable { value: unknown, prev_value?: unknown, ): boolean + /** Called for each connection that is created, updated, or removed. This includes "restored" connections when deserialising. */ onConnectionsChange?( this: LGraphNode, type: ISlotType, @@ -2456,9 +2457,15 @@ export class LGraphNode implements Positionable, IPinnable, IColorable { if (!graph) throw new NullGraphError() 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) - if (inputIndex === -1) return + if (inputIndex === -1) { + console.warn("connectSlots: input not found") + return + } // check targetSlot and check connection types if (!LiteGraph.isValidConnection(output.type, input.type)) {