ComfyUI-Custom-Scripts icon indicating copy to clipboard operation
ComfyUI-Custom-Scripts copied to clipboard

locking array cause JS error with ES6 litegraph classes

Open huchenlei opened this issue 1 year ago • 2 comments

See https://github.com/Comfy-Org/ComfyUI_frontend/issues/381.

Reproduction steps:

  • Checkout ComfyUI_frontend of version 1.2.17
  • Drag the png into the workspace.
  • Observe following error
TypeError: Cannot redefine property: 0
TypeError: Cannot redefine property: 0
    at Function.defineProperty (<anonymous>)
    at lockArray (http://127.0.0.1:8188/extensions/ComfyUI-Custom-Scripts/js/locking.js:13:10)
    at lockNode (http://127.0.0.1:8188/extensions/ComfyUI-Custom-Scripts/js/locking.js:117:5)
    at nodeType.onConfigure (http://127.0.0.1:8188/extensions/ComfyUI-Custom-Scripts/js/locking.js:181:5)
    at nodeType.onConfigure (http://127.0.0.1:8188/extensions/ComfyUI-Easy-Use/js/easy/easyWidgets.js:377:57)
    at o.configure (http://127.0.0.1:8188/assets/index-B3RD2RYX.js:1127:21807)
    at er.configure (http://127.0.0.1:8188/assets/index-B3RD2RYX.js:1127:18379)
    at LGraph.configure (http://127.0.0.1:8188/assets/index-B3RD2RYX.js:1438:7864)
    at LGraph.configure (http://127.0.0.1:8188/extensions/ComfyUI-Custom-Scripts/js/snapToGrid.js:160:21)
    at LGraph.configure (http://127.0.0.1:8188/extensions/ComfyUI-Custom-Scripts/js/reroutePrimitive.js:14:29)
This may be due to the following script:
/extensions/ComfyUI-Custom-Scripts/js/locking.js

huchenlei avatar Aug 12 '24 13:08 huchenlei

Just going to generalise my original comment: something that was [] Array is now an object. Possibly a Float32Array, but could also be an object like Record<number, any>.

webfiltered avatar Aug 12 '24 15:08 webfiltered

So LGraphNode.pos is Float32Array internally - I think it might have been for a while. There's an old-style getter/setter combo in litegraph to prevent consumers from overwriting its reference.

webfiltered avatar Aug 13 '24 05:08 webfiltered

Fixed by https://github.com/pythongosssss/ComfyUI-Custom-Scripts/commit/013894fa8278068d900ef56794ea66fd5bba33c6

huchenlei avatar Aug 27 '24 17:08 huchenlei