From b04ba0b1000489037b14b24b460716137c0202d4 Mon Sep 17 00:00:00 2001 From: Jakub Filo Date: Sun, 30 Apr 2023 16:43:59 +0000 Subject: [PATCH] Add a delay to calling client.disconnect as a workaround for it being called too early and websocket connection not being established. --- src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 709f01b..16b66a7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -127,7 +127,9 @@ async function run() { const client = new Client(username, password); await client.connect(); data.state = client.getState; - await client.disconnect(); + setTimeout(async () => { + await client.disconnect(); + }, 2000); } catch (err) { log.verbose("Failed to log in as new user, perhaps the password is wrong?"); log.silly(err);