Comfy-Org / Comfy-Org/ComfyUI_frontend
bug: detachGraphLayouts leaves partially-detached state if syncBoundsFromStore/syncPosition throws
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
## Bug
In `src/renderer/core/layout/operations/graphLayoutAttachment.ts:1553–1611`, `collect()` calls `group.syncBoundsFromStore()` and `reroute.syncPosition()` before clearing WeakMap entries. If either throws, the WeakMap entry is NOT cleared (leaked attachment) and the delete operation is never queued.
On the next `detachGraphLayouts` call the attachment re-appears and a redundant delete is attempted (no-op per idempotency), but the WeakMap leak is permanent until GC.
## Impact
A single exception during graph teardown (e.g. during workflow close/reload) can permanently leak layout attachments for groups and reroutes, preventing correct re-registration on the next load.
## Fix
Clear the WeakMap entry and set `_layoutRegistered = false` unconditionally first; push delete operations unconditionally; wrap sync calls in try/catch separately:
```ts
// Clear attachment first, unconditionally
groupAttachments.delete(group)
group._layoutRegistered = false
ops.push(deleteGroup(...))
// Then sync, isolated
try { group.syncBoundsFromStore() } catch (e) { console.error(e) }
```
_Filed as follow-up from review of #15017 (merged 2026-08-14)._
Contributor guide
Assessment
This issue has not been assessed yet.