From 3db44707faeb681c946f8deffdc37aae1468655e Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Mon, 7 Jul 2025 23:14:35 -0700 Subject: [PATCH] [fix] Clean up slot references when removing widgets (#1107) --- src/LGraphNode.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/LGraphNode.ts b/src/LGraphNode.ts index f284362ce..dd81cb7cc 100644 --- a/src/LGraphNode.ts +++ b/src/LGraphNode.ts @@ -1805,6 +1805,16 @@ export class LGraphNode implements NodeLike, Positionable, IPinnable, IColorable const widgetIndex = this.widgets.indexOf(widget) if (widgetIndex === -1) throw new Error("Widget not found on this node") + // Clean up slot references to prevent memory leaks + if (this.inputs) { + for (const input of this.inputs) { + if (input._widget === widget) { + input._widget = undefined + delete input.widget + } + } + } + this.widgets.splice(widgetIndex, 1) }