Troubleshooting
Why a Node-RED subflow env.get Boolean true crashes the function
Short answer
A subflow function that calls env.get on a Boolean property crashes the flow on Node-RED 3.1.7 paired with Node.js 14.20.0, but only when the property is true; the same property set to false returns correctly. Node.js 16 and later runs the same test cleanly, so the permanent fix is the firmware update that ships the newer runtime pair, with the property read routed out of env.get until then.

On this page
A subflow function that reads a Boolean property with env.get crashes Node-RED 3.1.7 when the property is true, and returns it correctly when the property is false. The boundary is the runtime pair Node-RED 3.1.7 with Node.js 14.20.0, which is exactly what firmware 3.6.0 ships on the EPIC PR1 after an upgrade from firmware 3.4.4 and Node-RED 2.2.2. Node.js 16 or later runs the identical flow without error, so the fix is the next firmware update that bumps both components together, and until then the property read has to leave the env.get path.
The failure boundary #
The reported case: firmware 3.4.4 ran the application on Node-RED 2.2.2 and it worked. Firmware 3.6.0 moved the application to Node-RED 3.1.7 and the subflow stopped. The same crash reproduced on a separate computer running Node-RED 3.1.7 with Node.js 14.20.0, and the same test flow ran clean once Node.js was 16 or later. That last result matters: it is not the controller hardware, it is the runtime tuple.
| Condition | Observed result |
|---|---|
| Firmware 3.4.4, Node-RED 2.2.2 | Subflow property read works |
| Firmware 3.6.0, Node-RED 3.1.7, Node.js 14.20.0 | Function crashes when the property is true, returns it when false |
| Node-RED 3.1.7 on a computer, Node.js 14.20.0 | Same split: false returns, true throws |
| Node-RED 3.1.7, Node.js 16 or later | Both Boolean states return correctly |
The true-versus-false split is the diagnostic key. A wiring mistake, a missing deployment or a misnamed property fails the same way regardless of the value; here only one Boolean state breaks. That asymmetry points at the value evaluation, not at the flow.
What Node-RED 3.1 changed #
The 3.1 release reworked how subflow environment variables are evaluated, moving much of that work through JSONata, and the release notes describe environment variables as statically defined values that cannot change while the flow runs, with edge cases called out around that change. The rework introduced defects in subflow property evaluation, and one of them was filed publicly as issue 4342 on the Node-RED repository, where subflow environment variables evaluate incorrectly from 3.1.0 onward; later Node-RED point releases have fixed at least some of these, which is why a managed device stuck on 3.1.7 keeps hitting it.
Inside a subflow, a function node reaches an instance property only through the environment API:
msg.payload = env.get("test_bool");
return msg;
The function expects env.get to resolve the property named test_bool, keep its Boolean type, and hand it to msg.payload. On the failing tuple the true-valued lookup throws instead.
Reproducing the crash in a minimal subflow at Node-RED 3.1.7 with Node.js 14.20.0 #
This is the worked case, built exactly as the reported minimal flow. The inputs: Node-RED 3.1.7 and Node.js 14.20.0 (the runtime pair the firmware upgrade produced, confirmed by checking the Node-RED startup log and the Node.js version output on the host); one subflow with a single environment property named test_bool of type bool, initially set to the string value "true"; one function node with the two lines above; one debug node configured to show complete: msg.payload; one inject node wired into the subflow instance to trigger it.
The rule under test: with everything else unchanged, only the Boolean value of test_bool is flipped between deploys, and the debug output tells you whether the lookup survives.
The test, run step by step:
- Set test_bool to false, deploy, inject. The debug node prints false, typed as Boolean. The lookup path itself works.
- Change only test_bool to true, redeploy, inject. The function node throws and the message stops at the subflow; the debug node receives nothing.
- Repeat the unchanged flow on the same Node-RED 3.1.7 but with Node.js 16 or later. Both states print correctly.
Result: the crash reproduces at the first tuple and disappears at the second, with the flow file held constant. The decision this test gives you: if your subflow property reads break after moving to Node-RED 3.1.7, and flipping one Boolean between false and true is what turns a clean return into a thrown error, you are on the documented 3.1 evaluation defect with the Node.js 14 runtime, and no amount of flow editing inside the function will fix it. Above all, do not conclude the flow is broken from a false-only test; that produces a false pass.
The fix: update the firmware that owns the runtime #
Use the device firmware path as the permanent correction. On a managed edge controller, firmware owns the embedded Node.js and Node-RED pair; replacing one component on its own creates an unmanaged combination nobody has tested. Keep the controller's runtime on the tested pairing the firmware package ships, and pick up the update that carries both the Node-RED bump past 3.1.x and the Node.js bump past 14. Later Node-RED releases include fixes for these subflow evaluation defects, so the bump closes the problem without any flow change. The same managed-runtime logic applies to other update-induced Node-RED faults on these controllers, such as the Node-RED HTTP 404 on a groov EPIC case: the fix arrives with the firmware, not with surgery on the installed runtime.
Until that firmware is installed on the unit, remove the property read from the affected execution path. A runtime compatibility defect is not something a redeploy, a permissions change or a different subflow layout corrects.
Workaround while you wait: route the value around env.get #
- Inventory every function inside the affected subflows that calls env.get, including nested subflows and each deployed instance of each subflow.
- Identify which of those lookups can ever receive a true Boolean, and prioritize them; false succeeding does not make the lookup safe on the next value change.
- Move the setting to an explicit input path you control, for example a property carried on msg into the subflow, or a fixed constant written into the function until firmware lands. Keep it a real Boolean: converting to text is a poor repair because a nonempty string such as "false" is truthy in JavaScript and silently flips branch decisions downstream.
- Deploy the modified flow and exercise both logical states, confirming at a debug node that the value and its type are correct.
- After the firmware update, rerun the minimal two-state test first, then restore the property-based configuration subflow by subflow so any regression stays isolated.
Diagnostic checklist #
- Record firmware, Node-RED and Node.js versions together as one tuple; a Node-RED version alone hides the Node.js boundary.
- Test the lookup with the property false and with it true, every time.
- Reproduce on a computer with the same Node-RED and Node.js versions before blaming the controller.
- Read the value and its type at the debug node, then follow the branch that consumes it downstream.
- Repeat the check after a cold application start, not only after a hot redeploy.
- Keep the reproduction flow free of custom nodes, context storage and unrelated logic so the comparison stays clean.
Verifying the corrected system #
A corrected system returns both Boolean states without a function exception, with the value arriving as a Boolean at the debug node and the downstream branch taking the expected path in each case. Verify once after deploy and once after a cold start, then restore each subflow's property-based configuration and retest that subflow before moving to the next. When the update is applied through the controller's own firmware process, record the new tuple in your notes so the next runtime jump is easy to compare. This whole class of problem sits with the edge runtime, not with the computer driving it; if the edge box itself is aging out of supported firmware, replacing it with a current fanless mini PC is the fallback once the fix is no longer available for it.
One safety note: if any subflow you modify gates a machine state or an operator action, test the workaround path with the machine in a safe state and restore the property-driven logic only after the firmware update passes the two-state test.
Questions asked
How do I reproduce the Node-RED env.get Boolean failure quickly?
Build a subflow with one Boolean property named test_bool and one function node containing msg.payload = env.get("test_bool"); return msg; plus a debug node on msg.payload. Run it on Node-RED 3.1.7 with Node.js 14.20.0. Set the property to false, deploy and inject: the value prints. Set it to true, redeploy and inject: the function throws. Repeating the unchanged flow on Node.js 16 or later succeeds on both states.
Why does the same function work when the property is false?
The defect is in how the 3.1 subflow environment evaluation handles a true Boolean value on the older runtime, not in your flow wiring. A missing or misnamed property would fail the same way for both states. The split between a clean false return and a crash on true is the signature that points to the runtime pair rather than to deployment or configuration errors.
Can I just store the property as a string to avoid the crash?
Not safely. In JavaScript a nonempty string such as "false" evaluates as truthy, so a function or switch node that branches on the value can take the wrong path even though no exception is thrown. If you reroute the setting while waiting for firmware, keep it a real Boolean and verify the type at the debug node, not just the printed text.
Which version tuple do I record when reporting or diagnosing this?
Record the device firmware, the Node-RED version and the Node.js version together as one tuple. On a managed edge controller the firmware owns both runtime components, so Node-RED 3.1.7 alone does not describe the boundary; the crash is specific to Node-RED 3.1.7 with Node.js 14.20.0, and Node.js 16 or later runs the identical flow without error.

