Interesting behaviour of empty Blockly node

Just while I'm testing other stuff out - I created the simplest flow with nothing in the Blockly node and just on a whim - pressed the inject - and was surprised that the timestamp went thru

Tried the same with empty function and it didn't

Like I say - interesting behaviour - I'll get back onto testing the big stuff :slight_smile:

And it shouldn't, if it's empty! :nerd_face:

However, a newly created function node contains return msg; by default, so the behaviour is consistent if you don't empty it manually. :wink:

1 Like

I am comparing like with like - I cleared the function node :slight_smile:

That could be Bart's intention - he'll call it a feature :slight_smile:

I've never tried the Blockly nodes, but if it's empty, I wouldn't expect it to output anything. :thinking:
Maybe you found a bug... :wink:

Whereas for an empty function, that would be the correct behaviour, because your script isn't returning any value.

It's a very slight bug and 99.999% of time msg.payload will be altered by user code so in practice, it'll never cause a real issue. :slight_smile:

Especially for us muggle coders who can't spull Javaship :slight_smile:

It's probably been there for past 5 years but only noticed it today during testing a more complex issue

1 Like

Hmm this one seems to be a hidden feature, not a bug :yum:

  1. When you add a new Blockly node to your flow, the default value of the javascript (see here) code is return msg;. And that code is indeed used in the VM that we start:


    So the message is passed through the Blockly node, and arrives on its output.

  2. However when you change e.g. the timeout setting in your node, the node is deployed again. The javascript tab is still empty (as before), but now the (empty) generated code is deployed:


    Since the VM doesn't return the input msg this time, the code - which processes the VM output - will see that there is nothing to be send to the output, and it will simply stop processing the VM output:


I think it is better if the default javascript code return msg; is replaced by no code, to match the default core Function node behaviour.

BTW the fact that the default return msg; javascript code is not showed in our Javascript tabsheet, is indeed a bug :shushing_face:

I mean when we initialize the (generated) javascript code to return msg;, we should also initialize the workspace xml to a Blockly workspace containing a block that sends the message to the output. Because the Blockly diagram and the generated Js code should always be in sync, which is now not the case: we have Js code for an empty Blockly workspace. That is not correct.

But it is more easy if we just start in a new Blockly node from an empty workspace and corresponding no Js code.

@cymplecy: Really nice catch that you find this one during testing!!
Only a pity that it took you five years... :rofl:


Tested your update on GitHub - works - no longer returns anything if blank

1 Like

Thanks Simon for confirming this!!
Enjoy your weekend!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.