bartbutenaers / node-red-contrib-blockly

A Node Red node for visual programming a function using Blockly
Apache License 2.0
88 stars 22 forks source link

fix blockly workspace serialization #116

Closed alicialics closed 10 months ago

alicialics commented 10 months ago

This serializes the Blockly workspace before Blockly gets reinitialized. This should fix https://groups.google.com/g/blockly/c/Rc5WiS8J1kc

This is a best effort PR so please do more testing

The issue is that loadResourcesFromServer is called multiple times, and each time a new Blockly instance is created.

So this is what happens:

loadResourcesFromServer is called and Blockly instance A is created A creates workspace W1 loadResourcesFromServer is called again and Blockly instance B is created B is used to serialize W1 (created by A) into XML and fails

This is a temporary fix that uses A to serialize W1 so B can use the serialized xml to create a new workspace. Ideally we should not be loading Blockly more than once but i'll leave it up to you.

bartbutenaers commented 10 months ago

@alicialics , Thanks again!! Merging it into the master branch to simplify testing. Kind regards, Bart

cymplecy commented 10 months ago

This has fixed the issue on my test instance :)

I can edit nodes with functions in them and no errors in console

image