Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix zombie linkIds on node deletion, add safety check (#7153)
Resolves #7152

- Adds a safety check to make sure link exists.
- Actually solves the problem by making sure the linkId is removed from
the subgraphOutput node when a node is deleted.

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-7153-Fix-zombie-linkIds-on-node-deletion-add-safety-check-2bf6d73d365081d98583e6a987431bd1)
by [Unito](https://www.unito.io)

---------

Co-authored-by: Alexander Brown <[email protected]>
  • Loading branch information
2 people authored and github-actions[bot] committed Dec 9, 2025
commit a87daa38fc65044e1b5a577d329e571fe2aac4f7
16 changes: 14 additions & 2 deletions src/lib/litegraph/src/LGraphNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { LayoutSource } from '@/renderer/core/layout/types'
import { adjustColor } from '@/utils/colorUtil'
import type { ColorAdjustOptions } from '@/utils/colorUtil'

import { SUBGRAPH_OUTPUT_ID } from '@/lib/litegraph/src/constants'
import type { DragAndScale } from './DragAndScale'
import type { LGraph } from './LGraph'
import { BadgePosition, LGraphBadge } from './LGraphBadge'
Expand Down Expand Up @@ -45,8 +46,8 @@ import type {
Rect,
Size
} from './interfaces'
import { LiteGraph } from './litegraph'
import type { LGraphNodeConstructor, Subgraph, SubgraphNode } from './litegraph'
import { LiteGraph, Subgraph } from './litegraph'
import type { LGraphNodeConstructor, SubgraphNode } from './litegraph'
import {
createBounds,
isInRect,
Expand Down Expand Up @@ -3074,6 +3075,17 @@ export class LGraphNode
for (const link_id of links) {
const link_info = graph._links.get(link_id)
if (!link_info) continue
if (
link_info.target_id === SUBGRAPH_OUTPUT_ID &&
graph instanceof Subgraph
) {
const targetSlot = graph.outputNode.slots[link_info.target_slot]
if (targetSlot) {
targetSlot.linkIds.length = 0
} else {
console.error('Missing subgraphOutput slot when disconnecting link')
}
}

const target = graph.getNodeById(link_info.target_id)
graph._version++
Expand Down
1 change: 1 addition & 0 deletions src/lib/litegraph/src/subgraph/SubgraphOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export class SubgraphOutput extends SubgraphSlot {
//should never have more than one connection
for (const linkId of this.linkIds) {
const link = subgraph.links[linkId]
if (!link) continue
subgraph.removeLink(linkId)
const { output, outputNode } = link.resolve(subgraph)
if (output)
Expand Down
Loading