Separate instances for each subflow node

I have created a subflow which receives some value as input. I store those values using a function in a flow variable which is then used in other nodes within the same subflow to cater my functionality. Now the problem arises, when i place two or more instances of the sublow in my main flow and give each some different input, the subflow flow variables from the first subflow are overridden by the input to other one.

Is there a way to keep all instances of subflows to have seperate memory or context?

1 Like

If you are storing in a flow context var then they should be seperate and not overwrite each other. Something else must be going on, maybe some JS object stored by reference issue.

Show us a minimal subflow that is showing the issue.

as this subflow works fine

[{"id":"d3651136368045cd","type":"subflow","name":"Subflow 1","info":"","category":"","in":[{"x":50,"y":30,"wires":[{"id":"a83559df57f283f8"}]}],"out":[{"x":160,"y":30,"wires":[{"id":"a83559df57f283f8","port":0}]}],"env":[],"meta":{},"color":"#DDAA99"},{"id":"a83559df57f283f8","type":"function","z":"d3651136368045cd","name":"function 158","func":"node.send({payload:flow.get(\"test\")})\nflow.set(\"test\",msg.payload)\nmsg.payload = flow.get(\"test\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":140,"wires":[[]]},{"id":"525c4676dbd2b99f","type":"subflow:d3651136368045cd","z":"0df28c03098e1a7f","name":"","env":[{"name":"prefix","value":"one","type":"str"}],"x":480,"y":660,"wires":[["1805d407ec75ef75"]]}]

If I am understanding correctly, in this flow, you are getting the flow variable and giving it a new value. Now if 2 subflows are running simultaneously, the value of flow variable is overriden by the latest assignment for all instances of the same subflow. Correct me if i am wrong?

As you can see in image below that no flow var is overwritten by the other subflow instance.

As said previously, share a minimal subflow example that show the issue of overwriting other subflow instances flow variable.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.