From c69279559010fbfb3e6ddb26400229450b8ae5be Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 12 Mar 2021 21:43:35 +0100 Subject: [PATCH] Fix instabilities with automatic login after restarts When many bundles are loaded nodecg takes it's time after a connection till all replicants are usable, which are required to do the login. Therefore this PR waits for about 200ms after the connection is established to let nodecg connect fully. --- nodecg-io-core/dashboard/authentication.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/nodecg-io-core/dashboard/authentication.ts b/nodecg-io-core/dashboard/authentication.ts index 35832da71..c4d4ec6d1 100644 --- a/nodecg-io-core/dashboard/authentication.ts +++ b/nodecg-io-core/dashboard/authentication.ts @@ -21,13 +21,16 @@ inputPassword?.addEventListener("keyup", function (event) { // Handler for when the socket.io client re-connects which is usually a nodecg restart. nodecg.socket.on("connect", () => { - // If a password has been entered previously try to directly login using it. - if (inputPassword.value !== "") { - loadFramework(); - } else { - updateLoadedStatus(); - updateFirstStartupLabel(); - } + // Give nodecg 200ms to fully connect so everything is usable. + setTimeout(() => { + // If a password has been entered previously try to directly login using it. + if (inputPassword.value !== "") { + loadFramework(); + } else { + updateLoadedStatus(); + updateFirstStartupLabel(); + } + }, 200); }); document.addEventListener("DOMContentLoaded", () => {