Function node & var definition

This looks like a design glitch in Node-RED ... or perhaps a feature:
The function node uses a sandbox (node.js terminology: context) that is initialized once and used throughout the life of the node. This sandbox acts like globalThis, explicitly proposed to run several scripts within that (preserving) context. Changes to the global scope (like variables defined accidentally globally by omitting let & friends) thus are reflected in sandbox and available for the next run of the function node.

I would like to propose @knolleary to verify if this is the intended functionality...

2 Likes