From 29dd892fd71281c1f33440daaad5a3f393e2e171 Mon Sep 17 00:00:00 2001 From: veeck Date: Mon, 3 Oct 2022 19:12:14 +0200 Subject: [PATCH 1/3] Wait till all nodeHelper promises are resolved before starting --- js/app.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/js/app.js b/js/app.js index c3d6b214de..670b62039e 100644 --- a/js/app.js +++ b/js/app.js @@ -226,17 +226,21 @@ function App() { httpServer = new Server(config, function (app, io) { Log.log("Server started ..."); + const nodePromises = []; + for (let nodeHelper of nodeHelpers) { nodeHelper.setExpressApp(app); nodeHelper.setSocketIO(io); - nodeHelper.start(); + nodePromises.push(nodeHelper.start()); } Log.log("Sockets connected & modules started ..."); - if (typeof callback === "function") { - callback(config); - } + Promise.all(nodePromises).then(() => { + if (typeof callback === "function") { + callback(config); + } + }); }); }); }); From e8de4192e788c59a555411dea335d4badfdaa3be Mon Sep 17 00:00:00 2001 From: veeck Date: Tue, 4 Oct 2022 17:22:06 +0200 Subject: [PATCH 2/3] Update with review suggestions --- js/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/app.js b/js/app.js index 670b62039e..bd3f81d25f 100644 --- a/js/app.js +++ b/js/app.js @@ -234,9 +234,9 @@ function App() { nodePromises.push(nodeHelper.start()); } - Log.log("Sockets connected & modules started ..."); + Promise.allSettled(nodePromises).then(() => { + Log.log("Sockets connected & modules started ..."); - Promise.all(nodePromises).then(() => { if (typeof callback === "function") { callback(config); } From afdaeec2a9ca9b60cd38f621a0018d0240f8262e Mon Sep 17 00:00:00 2001 From: veeck Date: Tue, 4 Oct 2022 17:25:53 +0200 Subject: [PATCH 3/3] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2c0484e8f..48954210e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Special thanks to: @rejas, @sdetweil ### Updated - Cleaned up test directory +- Wait for all modules to start before declaring the system ready (#2487) - Updated e2e tests (moved `done()` in helper functions) and use es6 syntax in all tests - Updated da translation - Rework weather module