fix: preserve lazily-created arrays during uninstrumentation cleanup

Addresses review feedback:
https://github.com/Comfy-Org/ComfyUI_frontend/pull/10496#discussion_r2990341198
This commit is contained in:
Christian Byrne
2026-03-26 09:17:42 -07:00
parent d123af9103
commit 38e0d8f684

View File

@@ -447,7 +447,23 @@ function restoreDescriptor(
if (descriptor) {
Object.defineProperty(node, prop, descriptor)
} else {
delete (node as unknown as Record<string, unknown>)[prop]
// The property did not exist before instrumentation.
// If it now holds a plain data value (e.g. an array populated while
// instrumented), preserve it instead of deleting — otherwise lazily
// created widgets/inputs/outputs arrays would be silently dropped.
const live = Object.getOwnPropertyDescriptor(node, prop)
if (live && !live.get && !live.set && live.value != null) {
// Replace the reactive getter/setter with a plain data descriptor
// so the value survives without Vue reactivity overhead.
Object.defineProperty(node, prop, {
value: live.value,
writable: true,
configurable: true,
enumerable: true
})
} else {
delete (node as unknown as Record<string, unknown>)[prop]
}
}
}