I know the order of creation of connectors impact the order of execution of the connected nodes. Until now, I assumed it was the only impact on execution of the order of creation of the connectors.
But now, I'm seeing strange stuffs happening, here is the story:
It wrote a quick and dirty attempt at playing with JSON & CBOR.
CBOR is a compact binary representation of JSON.
I found a JS library to handle the conversions. It uses ArrayBuffers to store its representations of CBOR.
So I created two different function nodes: one converting JSON->CBOR and another doing CBOR->JSON.
My quick and dirty implementation is to copy/paste the code of the library in a function node and replace msg.payload by its converted value.
So, piping JSON->CBOR and CBOR->JSON function nodes should return the original payload in JSON.
Try the attached flow and you will notice:
- pushing the 1st inject button causes no error and the output is correct
- pushing the 2nd inject button causes no error and the output is correct
- pushing the 3rd inject button causes the following error: "TypeError: First argument to DataView constructor must be an ArrayBuffer"
The only difference between the 2nd and the 3rd line of my flow is the order of creation of the connectors:
On the 2nd line:
- I first piped the output of JSON->CBOR to CBOR->JSON
- Then I piped the output of JSON->CBOR to the intermediate debug node
On the 3rd line:
- I first piped the output of JSON->CBOR to the intermediate debug node
- Then I piped the output of JSON->CBOR to CBOR->JSON
So it seems to me that the debug node somehow "back modifies" the payload that will then fed to the CBOR->JSON functions. From my understanding, both these nodes should have got the same immutable message to process as their input is fed from the same node. It seems it is not the case.
Did I miss something about Node-RED principles or did I just found an bug ?
nodered_typing_flow_ordering.json (79.3 KB)