Skip to content

Commit 4a74562

Browse files
fix: Add guards for _listenerController.abort() calls in SubgraphNode (#4968)
This fix adds guards before calling `_listenerController.abort()` to prevent runtime errors when loading workflows. The guards check that `_listenerController` exists and has an `abort` function before calling it, matching the pattern used in Comfy-Org/litegraph.js#1134. Fixes #4907 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-4968-fix-Add-guards-for-_listenerController-abort-calls-in-SubgraphNode-24e6d73d3650813ebeeed69ee676faeb) by [Unito](https://www.unito.io)
1 parent a9c80e9 commit 4a74562

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/lib/litegraph/src/subgraph/SubgraphNode.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,12 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph {
171171
subgraphInput: SubgraphInput,
172172
input: INodeInputSlot & Partial<ISubgraphInput>
173173
) {
174-
input._listenerController?.abort()
174+
if (
175+
input._listenerController &&
176+
typeof input._listenerController.abort === 'function'
177+
) {
178+
input._listenerController.abort()
179+
}
175180
input._listenerController = new AbortController()
176181
const { signal } = input._listenerController
177182

@@ -207,7 +212,12 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph {
207212

208213
override configure(info: ExportedSubgraphInstance): void {
209214
for (const input of this.inputs) {
210-
input._listenerController?.abort()
215+
if (
216+
input._listenerController &&
217+
typeof input._listenerController.abort === 'function'
218+
) {
219+
input._listenerController.abort()
220+
}
211221
}
212222

213223
this.inputs.length = 0
@@ -518,7 +528,12 @@ export class SubgraphNode extends LGraphNode implements BaseLGraph {
518528
}
519529

520530
for (const input of this.inputs) {
521-
input._listenerController?.abort()
531+
if (
532+
input._listenerController &&
533+
typeof input._listenerController.abort === 'function'
534+
) {
535+
input._listenerController.abort()
536+
}
522537
}
523538
}
524539
}

0 commit comments

Comments
 (0)