timeout
This commit is contained in:
parent
a7cf6d62ac
commit
7dce63af7d
1 changed files with 4 additions and 4 deletions
|
|
@ -79,11 +79,11 @@ export class LiquidityProvider {
|
||||||
|
|
||||||
Connect = async () => {
|
Connect = async () => {
|
||||||
await new Promise(res => setTimeout(res, 2000))
|
await new Promise(res => setTimeout(res, 2000))
|
||||||
this.log("ready")
|
|
||||||
const res = await this.GetUserState()
|
const res = await this.GetUserState()
|
||||||
if (res.status === 'ERROR') {
|
if (res.status === 'ERROR' && res.reason !== 'timeout') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
this.log("provider ready with balance:", res.status === 'OK' ? res.balance : 0)
|
||||||
this.ready = true
|
this.ready = true
|
||||||
this.queue.forEach(q => q('ready'))
|
this.queue.forEach(q => q('ready'))
|
||||||
this.log("subbing to user operations")
|
this.log("subbing to user operations")
|
||||||
|
|
@ -101,9 +101,9 @@ export class LiquidityProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
GetUserState = async () => {
|
GetUserState = async () => {
|
||||||
const res = await this.client.GetUserInfo()
|
const res = await Promise.race([this.client.GetUserInfo(), new Promise<Types.ResultError>(res => setTimeout(() => res({ status: 'ERROR', reason: 'timeout' }), 10 * 1000))])
|
||||||
if (res.status === 'ERROR') {
|
if (res.status === 'ERROR') {
|
||||||
this.log("error getting user info", res)
|
this.log("error getting user info", res.reason)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
this.utils.stateBundler.AddBalancePoint('providerBalance', res.balance)
|
this.utils.stateBundler.AddBalancePoint('providerBalance', res.balance)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue