Is payload required by design or is it a bug?

The docs say:

Messages usually have a payload property - this is the default property that most nodes will work with.

What about nodes that don't work with payload, but just pass the message?
Is payload property required (i.e. intended so by design) for them to function properly?

I am asking because:

and I don't think this is a correct response from Node-RED.

Even if the payload property was required by design, the error message could be more informational, rather than:

"TypeError: Cannot read property 'req' of undefined"

Shall I submit a new issue on GitHub?


The code:

[{"id":"980a0f42.21944","type":"trigger","z":"bf313411.baefb8","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"2","extend":true,"units":"s","reset":"","bytopic":"all","name":"trigger 2s","x":600,"y":120,"wires":[["e476e237.62452"]]},{"id":"67dfcc82.61e904","type":"inject","z":"bf313411.baefb8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":100,"wires":[["e4c25eb6.bae79","c45993a0.db376"]]},{"id":"e476e237.62452","type":"debug","z":"bf313411.baefb8","name":"this doesn't","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":750,"y":120,"wires":[]},{"id":"e4c25eb6.bae79","type":"function","z":"bf313411.baefb8","name":"emit new message with no payload","func":"var new_msg = {};\n\nnew_msg.key1 = \"value1\";\nnew_msg.key2 = \"value2\";\n\nreturn new_msg;","outputs":1,"noerr":0,"x":380,"y":120,"wires":[["980a0f42.21944"]]},{"id":"c45993a0.db376","type":"function","z":"bf313411.baefb8","name":"emit new message with payload","func":"var new_msg = {};\n\nnew_msg.key1 = \"value1\";\nnew_msg.key2 = \"value2\";\nnew_msg.payload = true;\n\nreturn new_msg;","outputs":1,"noerr":0,"x":370,"y":80,"wires":[["b91be038.da8f1"]]},{"id":"b91be038.da8f1","type":"trigger","z":"bf313411.baefb8","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"1","extend":true,"units":"s","reset":"","bytopic":"all","name":"trigger 1s","x":600,"y":80,"wires":[["b29fd727.5dd278"]]},{"id":"b29fd727.5dd278","type":"debug","z":"bf313411.baefb8","name":"this works","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":750,"y":80,"wires":[]}]

well importing your flow works for me... :slight_smile:

But then the export has both triggers set to 1 sec - so maybe you have it configured differently ?
image

You are hitting this known issue: https://github.com/node-red/node-red/issues/2399

That is already fixed and will be in 1.0.4 - which is the code @dceejay is already running which is why it works for him.

2 Likes

Sorry, you must have taken the code from my initial message, but looked at the image from the latest edit.

I decided to make some beautification and replaced both: the code and the image to avoid confusion, yet I created one :slight_smile:

Oh, shame on me.

Thanks for the answer.

Just good timing, as 1.0.4 is coming soon

1 Like

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