diff --git a/src/app/page.tsx b/src/app/page.tsx index 8b3c2fc..6df6911 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -47,7 +47,8 @@ const Page = () => { // periodically check if the websocket connection is still alive useEffect(() => { - const interval = setInterval(() => { + + function connectionChecker() { // wait for appConfig to be fetched if (!appConfig) { console.log("AppConfig not fetched yet"); @@ -75,7 +76,19 @@ const Page = () => { }); } + } + + // run once on startup + setTimeout(() => { + connectionChecker(); + }, 10); + + // run every 2 seconds + const interval = setInterval(() => { + connectionChecker(); }, 2000); + + return () => clearInterval(interval); }, [appConfig]);