From 687b9e659c7393bee7093ea0c53945a61dc10ece Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Tue, 23 Sep 2025 04:13:38 +1000 Subject: [PATCH] Fix reroute ID 0 treated as invalid (#5723) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Fixes old logic bug from refactor https://github.com/Comfy-Org/litegraph.js/pull/602/files ## Changes - Fixes truthy refactor to explicitly check undefined ## Review Focus No expectation that this will impact prod, however it may impact extensions IF someone has explicitly been setting link parentId to 0. This would be very strange, as it would cause unexpected behaviour in other parts of the code (which all explicitly check `undefined`). ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5723-Fix-reroute-ID-0-treated-as-invalid-2766d73d365081568124ce1f85cdf84e) by [Unito](https://www.unito.io) --- src/lib/litegraph/src/LLink.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/litegraph/src/LLink.ts b/src/lib/litegraph/src/LLink.ts index 58ae4e090..71b41f23d 100644 --- a/src/lib/litegraph/src/LLink.ts +++ b/src/lib/litegraph/src/LLink.ts @@ -205,7 +205,7 @@ export class LLink implements LinkSegment, Serialisable { network: Pick, linkSegment: LinkSegment ): Reroute[] { - if (!linkSegment.parentId) return [] + if (linkSegment.parentId === undefined) return [] return network.reroutes.get(linkSegment.parentId)?.getReroutes() ?? [] } @@ -229,7 +229,7 @@ export class LLink implements LinkSegment, Serialisable { linkSegment: LinkSegment, rerouteId: RerouteId ): Reroute | null | undefined { - if (!linkSegment.parentId) return + if (linkSegment.parentId === undefined) return return network.reroutes .get(linkSegment.parentId) ?.findNextReroute(rerouteId) @@ -498,7 +498,7 @@ export class LLink implements LinkSegment, Serialisable { target_slot: this.target_slot, type: this.type } - if (this.parentId) copy.parentId = this.parentId + if (this.parentId !== undefined) copy.parentId = this.parentId return copy } }