1

In NodeRed, I am seeing a different message payload sent to two debug nodes that are connected to the same output.

Two debug nodes on a single output

Here is the debug output. Take note of the identical message id, and the different 'bri' value.

enter image description here

When I export the nodes, it all looks correct:

[
{
    "id": "5e606454b87b03b5",
    "type": "AnamicoLightChanged",
    "z": "34538bcf724fc14b",
    "name": "${LIGHT_NAME}",
    "lights": "14cd068baff7afb8",
    "mode": "LIFX",
    "x": 1240,
    "y": 300,
    "wires": [
        [
            "6c7a0670390f6da6",
            "5b8374e42193a04d"
        ]
    ]
},
{
    "id": "6c7a0670390f6da6",
    "type": "debug",
    "z": "34538bcf724fc14b",
    "name": "LS OUT 1",
    "active": true,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "true",
    "targetType": "full",
    "statusVal": "",
    "statusType": "auto",
    "x": 1500,
    "y": 260,
    "wires": []
},
{
    "id": "5b8374e42193a04d",
    "type": "debug",
    "z": "34538bcf724fc14b",
    "name": "LS OUT 2",
    "active": true,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "true",
    "targetType": "full",
    "statusVal": "",
    "statusType": "auto",
    "x": 1500,
    "y": 340,
    "wires": []
},
{
    "id": "14cd068baff7afb8",
    "type": "AnamicoLights",
    "name": "Anamico Lights"
}
]

Can anyone give me an explanation as to what could cause this? Is it something the source node (https://github.com/Anamico/node-red-contrib-light) is doing wrong somehow? Or is it something I am not understanding about the way NodeRed works?

1 Answers1

1

Everything in NodeJS is pass by reference, so it appears that something in the node is sharing a reference to a single msg object and updating it in the gap between the 2 debug nodes processing the message.

They should be the "same" msg object because the msg._msgid is the same. which also leads to the assumption that something is updating the msg.payload independently.

This feels to me that there is something strange in the Anamico node, but it will take time to dissect it to work out what.

hardillb
  • 12,813
  • 1
  • 21
  • 34