diff --git a/packages/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js b/packages/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js index 9798fd7b8..151ba62ef 100644 --- a/packages/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js +++ b/packages/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js @@ -247,6 +247,7 @@ class Flow { if (!stopList) { stopList = Object.keys(this.activeNodes); } + // this.trace(" stopList: "+stopList.join(",")) // Convert the list to a map to avoid multiple scans of the list var removedMap = {}; removedList = removedList || []; @@ -261,8 +262,9 @@ class Flow { delete this.activeNodes[stopList[i]]; if (this.subflowInstanceNodes[stopList[i]]) { try { - var subflow = this.subflowInstanceNodes[stopList[i]]; - promises.push(stopNode(node,false).then(() => { subflow.stop() })); + (function(subflow) { + promises.push(stopNode(node,false).then(() => { subflow.stop() })); + })(this.subflowInstanceNodes[stopList[i]]); } catch(err) { node.error(err); }