Merge pull request #2880 from node-red/stop-order

Stop config nodes after flow nodes
This commit is contained in:
Nick O'Leary
2021-02-25 15:58:39 +00:00
committed by GitHub
3 changed files with 56 additions and 3 deletions

View File

@@ -308,6 +308,17 @@ class Flow {
removedMap[id] = true;
});
let nodesToStop = [];
let configsToStop = [];
stopList.forEach(id => {
if (this.flow.configs[id]) {
configsToStop.push(id);
} else {
nodesToStop.push(id);
}
});
stopList = nodesToStop.concat(configsToStop);
var promises = [];
for (i=0;i<stopList.length;i++) {
var node = this.activeNodes[stopList[i]];

View File

@@ -404,7 +404,15 @@ function stop(type,diff,muteLog) {
events.emit("flows:stopping",{config: activeConfig, type: type, diff: diff})
for (var id in activeFlows) {
// Stop the global flow object last
let activeFlowIds = Object.keys(activeFlows);
let globalIndex = activeFlowIds.indexOf("global");
if (globalIndex !== -1) {
activeFlowIds.splice(globalIndex,1);
activeFlowIds.push("global");
}
activeFlowIds.forEach(id => {
if (activeFlows.hasOwnProperty(id)) {
var flowStateChanged = diff && (diff.added.indexOf(id) !== -1 || diff.removed.indexOf(id) !== -1);
log.debug("red/nodes/flows.stop : stopping flow : "+id);
@@ -413,10 +421,10 @@ function stop(type,diff,muteLog) {
delete activeFlows[id];
}
}
}
});
return Promise.all(promises).then(function() {
for (id in activeNodesToFlow) {
for (let id in activeNodesToFlow) {
if (activeNodesToFlow.hasOwnProperty(id)) {
if (!activeFlows[activeNodesToFlow[id]]) {
delete activeNodesToFlow[id];