I recently upgraded my EPIC PR1 fw from 3.4.4 to 3.6.0. Unfortunately, my node-red application stopped working when moving from node-red version 2.2.2 to 3.1.7.
I was able to isolate the error to one of my subflows that uses
env.get("key")
inside a function node to access the subflow properties.
The env.get function simply doesn’t work after upgrading fw (node-red version).
I created a simple flow as an example.
A simple flow that prints the subflow property test_bool. What’s interesting is that the code crashes when i set test_bool to true, and prints it correctly when I set it to false…
I was able to reproduce this bug running node-red on my computer as well and found out that the problem occurs when I use node-red 3.1.7 together with node version 14.20.0. When I tested with node version 16.+, it all worked fine.
As far as I know, env.get is the only way to get property values in function nodes in subflows. If you have any workarounds, please let me know. I will stop using the properties for now.
Here is my test flow:
[{“id”:“120baba834766ba3”,“type”:“tab”,“label”:“Flow 1”,“disabled”:false,“info”:“”,“env”:},{“id”:“b140530477a83e84”,“type”:“subflow”,“name”:“Test Subflow”,“info”:“”,“category”:“”,“in”:[{“x”:60,“y”:80,“wires”:[{“id”:“a7a7b863a4372a04”}]}],“out”:,“env”:[{“name”:“test_bool”,“type”:“bool”,“value”:“true”}],“meta”:{},“color”:“#DDAA99”},{“id”:“a7a7b863a4372a04”,“type”:“function”,“z”:“b140530477a83e84”,“name”:“function 1”,“func”:“msg.payload = env.get("test_bool");\nreturn msg;”,“outputs”:1,“timeout”:0,“noerr”:0,“initialize”:“”,“finalize”:“”,“libs”:,“x”:200,“y”:80,“wires”:[[“91971d1928fa6b17”]]},{“id”:“91971d1928fa6b17”,“type”:“debug”,“z”:“b140530477a83e84”,“name”:“debug 1”,“active”:true,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“payload”,“targetType”:“msg”,“statusVal”:“”,“statusType”:“auto”,“x”:360,“y”:80,“wires”:},{“id”:“2bcdd1fd190577f2”,“type”:“inject”,“z”:“120baba834766ba3”,“name”:“”,“props”:[{“p”:“payload”},{“p”:“topic”,“vt”:“str”}],“repeat”:“”,“crontab”:“”,“once”:false,“onceDelay”:0.1,“topic”:“”,“payload”:“”,“payloadType”:“date”,“x”:400,“y”:100,“wires”:[[“8a4e0083c0815dab”]]},{“id”:“8a4e0083c0815dab”,“type”:“subflow:b140530477a83e84”,“z”:“120baba834766ba3”,“name”:“Test”,“x”:610,“y”:100,“wires”:}]