Cloning behavior

#1

While playing with debug nodes I get the feeling that simply adding a debug node seems to change the msg passing (against my beliefs). When triggering the first flow I see the property msg.res being deleted (apparently) resulting in undefined being displayed in the debug panel. The second flow is the same as the first one, except that I unwired the first debug node. When triggering this second flow the debug panel reveals that msg.res holds the expected value. I am aware that adding a second wire to the function node will result in cloning of the message but was not expecting a property being removed (if this is indeed the case). Also, it is puzzling is that sometimes I can not repeat this behavior when creating everything from scratch. Can someone test the flow and tell me if you can observe the same behavior?

[{"id":"16a4fcea.3bbe53","type":"tab","label":"Cloning","disabled":false,"info":""},{"id":"31fb332.03249cc","type":"inject","z":"16a4fcea.3bbe53","name":"G","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":80,"wires":[["6ab2295a.411b08"]]},{"id":"c5781ff8.01f48","type":"debug","z":"16a4fcea.3bbe53","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","x":530,"y":80,"wires":[]},{"id":"6ab2295a.411b08","type":"function","z":"16a4fcea.3bbe53","name":"msg.res = false","func":"msg.res = false;\nreturn msg;","outputs":1,"noerr":0,"x":340,"y":80,"wires":[["c5781ff8.01f48","657870dd.cc5db"]]},{"id":"657870dd.cc5db","type":"debug","z":"16a4fcea.3bbe53","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"res","targetType":"msg","x":540,"y":140,"wires":[]},{"id":"fd8b9eb7.02fbc","type":"inject","z":"16a4fcea.3bbe53","name":"G","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":280,"wires":[["36ee1ed9.3ed082"]]},{"id":"a75f727f.b2413","type":"debug","z":"16a4fcea.3bbe53","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","x":530,"y":280,"wires":[]},{"id":"36ee1ed9.3ed082","type":"function","z":"16a4fcea.3bbe53","name":"msg.res = false","func":"msg.res = false;\nreturn msg;","outputs":1,"noerr":0,"x":340,"y":280,"wires":[["85a0f428.9dffb8"]]},{"id":"85a0f428.9dffb8","type":"debug","z":"16a4fcea.3bbe53","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"res","targetType":"msg","x":520,"y":340,"wires":[]}]
0 Likes

#2

You've hit an edge case here.

The clone function we use explicitly does not clone msg.req and msg.res - they are well known properties used by the HTTP In node which cannot be cloned.

Try you tests again with literally any other property name and I suspect you'll find a much more consistent result.

1 Like

#3

Indeed, testing with another name property works perfectly, which also explains why I could not reproduce the issue in my second attempt (I selected another property name at random). Thank you very much Nick.

0 Likes