A bit of background on how all this happened:
A function node code - example:
if (x = 3)
{
payload = "a"
}
else
{
payload = "b"
}
msg.payload = payload
return msg
That is fine.
But if you make it:
if (x = 3)
{
payload = "a"
}
else
{
payload = null
}
msg.payload = payload
return msg
That's a whole other story.
And it is different to:
return null
Here is an example flow that shows this problem with what happens in the function node and the return stuff.
[{"id":"a8d589a97ea51bd6","type":"inject","z":"6cf51e98651df17b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":2150,"y":3960,"wires":[["4934260b228560e0"]]},{"id":"4934260b228560e0","type":"function","z":"6cf51e98651df17b","name":"function 4","func":"if (msg.payload == \"A\")\n{\n msg.payload = \"ONE\"\n}\nelse\n{\n msg.payload = null\n}\nlet msg1 = {}\nmsg1.payload = null\nreturn [msg,msg1]","outputs":2,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2320,"y":3960,"wires":[["2a2a5d4f64c61a24"],["397d9434427bd94e"]]},{"id":"2a2a5d4f64c61a24","type":"change","z":"6cf51e98651df17b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Hello","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2520,"y":3940,"wires":[["b3584d6abc3f725b"]]},{"id":"b3584d6abc3f725b","type":"debug","z":"6cf51e98651df17b","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2670,"y":3940,"wires":[]},{"id":"ddc48bb67e382bd8","type":"debug","z":"6cf51e98651df17b","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2670,"y":3980,"wires":[]},{"id":"397d9434427bd94e","type":"change","z":"6cf51e98651df17b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Hello","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2520,"y":3980,"wires":[["ddc48bb67e382bd8"]]},{"id":"3008b7d591a739e7","type":"function","z":"6cf51e98651df17b","name":"function 5","func":"if (msg.payload == \"A\")\n{\n msg.payload = \"ONE\"\n}\nelse\n{\n msg.payload = null\n}\nreturn [msg,null]","outputs":2,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2320,"y":4040,"wires":[["d3acbad355dbc6d2"],["c3321f12e6d7e7d0"]]},{"id":"1c03674fbcc6a8a0","type":"inject","z":"6cf51e98651df17b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":2150,"y":4040,"wires":[["3008b7d591a739e7"]]},{"id":"d3acbad355dbc6d2","type":"change","z":"6cf51e98651df17b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Hello","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2520,"y":4020,"wires":[["2f2da2919cf7c2b5"]]},{"id":"c3321f12e6d7e7d0","type":"change","z":"6cf51e98651df17b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Hello","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2520,"y":4060,"wires":[["d10e0fb321c17e60"]]},{"id":"2f2da2919cf7c2b5","type":"debug","z":"6cf51e98651df17b","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2670,"y":4020,"wires":[]},{"id":"d10e0fb321c17e60","type":"debug","z":"6cf51e98651df17b","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2670,"y":4060,"wires":[]}]
That also shows this problem happening.
(Screen shot for the sake of it.)
Compare the code in function 4 and function 5.