From 7dce63af7d4fba49b33eb8ee2ebe25591d6cde77 Mon Sep 17 00:00:00 2001 From: boufni95 Date: Sun, 14 Jul 2024 16:38:25 +0200 Subject: [PATCH] timeout --- src/services/main/liquidityProvider.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/services/main/liquidityProvider.ts b/src/services/main/liquidityProvider.ts index c1249690..6fc6d7f5 100644 --- a/src/services/main/liquidityProvider.ts +++ b/src/services/main/liquidityProvider.ts @@ -79,11 +79,11 @@ export class LiquidityProvider { Connect = async () => { await new Promise(res => setTimeout(res, 2000)) - this.log("ready") const res = await this.GetUserState() - if (res.status === 'ERROR') { + if (res.status === 'ERROR' && res.reason !== 'timeout') { return } + this.log("provider ready with balance:", res.status === 'OK' ? res.balance : 0) this.ready = true this.queue.forEach(q => q('ready')) this.log("subbing to user operations") @@ -101,9 +101,9 @@ export class LiquidityProvider { } GetUserState = async () => { - const res = await this.client.GetUserInfo() + const res = await Promise.race([this.client.GetUserInfo(), new Promise(res => setTimeout(() => res({ status: 'ERROR', reason: 'timeout' }), 10 * 1000))]) if (res.status === 'ERROR') { - this.log("error getting user info", res) + this.log("error getting user info", res.reason) return res } this.utils.stateBundler.AddBalancePoint('providerBalance', res.balance)