From 814c1f601406f48767ac3f0bbdfd7c7f994d1c2f Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 25 Aug 2024 22:47:52 -0400 Subject: [PATCH] concurrency is tough! --- backend/controllers/systems.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/controllers/systems.js b/backend/controllers/systems.js index a828bce..a3fa228 100644 --- a/backend/controllers/systems.js +++ b/backend/controllers/systems.js @@ -107,7 +107,7 @@ async function load_systems(systemClients) { //const results = await System.find({active: true}).catch( err => { // super simple query console.error("Error - get_systems: " + err.message); }); - systemList = []; + tempList = []; for (var result in results) { var clientCount = 0; @@ -137,8 +137,10 @@ async function load_systems(systemClients) { system.screenName = null; }*/ system.screenName = null; - systemList.push(system); + tempList.push(system); } + // don't update the systemList until we have all the data or else load_systems will be called multiple times + systemList = tempList; console.log("Loaded Systems: " + systemList.length + " that have been active since: " + fromDate); }