@knolleary - I've been able to reproduce the error the OP gets with the attached flow. I wonder if this is both a bug and the user accessing the contect object incorrectly which triggers the error.
First the bug: With the attached flow, Under the comment 'Vannila version' press the inject node and in the debug you will see the timestamp. Next swap to 'Flow 2' - nothing happens (even monitoring the log) now swap back to 'Flow 1' and I receive the error the OP posted.
Second the incorrect access of the contect object. My theory is that the way the function tries to access the 'contect' object is incorrect. (It may have been correct before the persistent option was added - as a side note the node 'node-red-contrib-contextbrowser' now throws an error and I will open an issue about that in GitHub).
If you restart NR and run the flow under the comment '`Debug version' you will see the OP's code returns 'get', 'set' and 'keys' which are not the names of flow variables set by the user.
So two questions:
- how do you now list all the flow variables set
and
- is the situation the user has a bug or caused by the change in accessing the names of flow variables?
The exttra flows are for adding and displaying a flow variable and dumping the contect object. And a demo
showing flow variables do not work in function nodes using the flow.get/set format. (change nodes don't work eithor.)
Flow to reproduce this follows:
[{"id":"510516ec.7bad18","type":"inject","z":"c20906ef.52b988","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"0.1","x":180,"y":100,"wires":[["3a568dd.06a2172"]]},{"id":"3a568dd.06a2172","type":"function","z":"c20906ef.52b988","name":"OnFlowsLoad","func":"// Delete all flow variables except global referenced variable.\nfor (var variableName in context.flow) {\n if (variableName !== \"global\")\n {\n delete context.flow[variableName];\n }\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":400,"y":100,"wires":[["2d0a461f.fd3232"]]},{"id":"205c6d34.40afe2","type":"catch","z":"c20906ef.52b988","name":"","scope":null,"x":620,"y":560,"wires":[["c9c65c0b.e2dea8"]]},{"id":"c9c65c0b.e2dea8","type":"debug","z":"c20906ef.52b988","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":810,"y":560,"wires":[]},{"id":"2d0a461f.fd3232","type":"debug","z":"c20906ef.52b988","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":630,"y":100,"wires":[]},{"id":"2af14454.477944","type":"inject","z":"c20906ef.52b988","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"0.1","x":180,"y":340,"wires":[["c38e2a00.f1428"]]},{"id":"c38e2a00.f1428","type":"function","z":"c20906ef.52b988","name":"Dump context object","func":"msg.payload = context;\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":340,"wires":[["3f3c3bc.252db44"]]},{"id":"3f3c3bc.252db44","type":"debug","z":"c20906ef.52b988","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":630,"y":340,"wires":[]},{"id":"9a3c422.1f73ec","type":"inject","z":"c20906ef.52b988","name":"","topic":"","payload":"Happy trails","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":460,"wires":[["ab0068ce.b309c"]]},{"id":"ae468489.40884","type":"inject","z":"c20906ef.52b988","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":500,"wires":[["3472f453.04841c"]]},{"id":"54f2571a.f84188","type":"debug","z":"c20906ef.52b988","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":650,"y":500,"wires":[]},{"id":"71887d9.00be704","type":"comment","z":"c20906ef.52b988","name":"Vannila version","info":"","x":180,"y":60,"wires":[]},{"id":"1e301b7e.92fdf5","type":"inject","z":"c20906ef.52b988","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"0.1","x":180,"y":220,"wires":[["3801e321.50859c"]]},{"id":"3801e321.50859c","type":"function","z":"c20906ef.52b988","name":"OnFlowsLoad","func":"// Delete all flow variables except global referenced variable.\nfor (var variableName in context.flow) {\n node.warn(\"debug1:\"+ variableName);\n if (variableName !== \"global\")\n {\n delete context.flow[variableName];\n }\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":400,"y":220,"wires":[["2b73f2a5.7fa04e"]]},{"id":"2b73f2a5.7fa04e","type":"debug","z":"c20906ef.52b988","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":630,"y":220,"wires":[]},{"id":"801a7e3c.caa7d8","type":"comment","z":"c20906ef.52b988","name":"Debug version","info":"","x":180,"y":180,"wires":[]},{"id":"d20dd1fd.3bf108","type":"comment","z":"c20906ef.52b988","name":"Debug version","info":"","x":180,"y":300,"wires":[]},{"id":"c26c178d.f2fc88","type":"comment","z":"c20906ef.52b988","name":"Debug version","info":"","x":180,"y":420,"wires":[]},{"id":"a7a51c21.ef657","type":"debug","z":"c20906ef.52b988","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":650,"y":460,"wires":[]},{"id":"4f582c9e.89915c","type":"change","z":"c20906ef.52b988","name":"dump the flow variable","rules":[{"t":"move","p":"test","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":560,"wires":[[]]},{"id":"ab0068ce.b309c","type":"function","z":"c20906ef.52b988","name":"Create flow variable","func":"flow.set(\"myData\", msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":440,"y":460,"wires":[["a7a51c21.ef657"]]},{"id":"3472f453.04841c","type":"function","z":"c20906ef.52b988","name":"Create flow variable","func":"var x = flow.get(\"myData\");\nreturn msg;","outputs":1,"noerr":0,"x":440,"y":500,"wires":[["54f2571a.f84188"]]}]