From 55c8fc8aba5dfb5ff3c66a11946f85ec631b1d41 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Thu, 10 Dec 2020 14:17:06 +0100 Subject: [PATCH] perf(client): Await timeouts only in recursive connects --- src/client.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index 72e06c25..95bd37b1 100644 --- a/src/client.ts +++ b/src/client.ts @@ -288,7 +288,9 @@ export function createClient(options: ClientOptions): Client { } // if recursive call, wait a bit for socket change - await new Promise((resolve) => setTimeout(resolve, callDepth * 50)); + if (callDepth) { + await new Promise((resolve) => setTimeout(resolve, callDepth * 50)); + } // socket already exists. can be ready or pending, check and behave accordingly if (state.socket) {