From afa69f4c0e901d080e294a3944f0296fa603ca7a Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 15 Mar 2019 09:13:32 +0000 Subject: [PATCH] Ensure all subflow instances are stopped when flow stopping Fixes #2095 --- .../node_modules/@node-red/runtime/lib/nodes/flows/Flow.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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); }