UBERF-8899: Reconnect performance issues (#7611)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2025-01-09 11:15:06 +07:00
committed by GitHub
parent d63db0fca6
commit 12e0aaa5f7
12 changed files with 73 additions and 52 deletions
+9 -3
View File
@@ -44,6 +44,7 @@ import core, {
TxApplyIf,
TxHandler,
TxResult,
clone,
generateId,
toFindResult,
type MeasureContext
@@ -108,6 +109,8 @@ class Connection implements ClientConnection {
private helloRecieved: boolean = false
private account: Account | undefined
onConnect?: (event: ClientConnectEvent, lastTx: string | undefined, data: any) => Promise<void>
rpcHandler = new RPCHandler()
@@ -303,7 +306,7 @@ class Connection implements ClientConnection {
this.websocket?.close()
return
}
this.account = helloResp.account
this.helloRecieved = true
if (this.upgrading) {
// We need to call upgrade since connection is upgraded
@@ -322,8 +325,8 @@ class Connection implements ClientConnection {
}
void this.onConnect?.(
(resp as HelloResponse).reconnect === true ? ClientConnectEvent.Reconnected : ClientConnectEvent.Connected,
(resp as HelloResponse).lastTx,
helloResp.reconnect === true ? ClientConnectEvent.Reconnected : ClientConnectEvent.Connected,
helloResp.lastTx,
this.sessionId
)
this.schedulePing(socketId)
@@ -635,6 +638,9 @@ class Connection implements ClientConnection {
}
getAccount (): Promise<Account> {
if (this.account !== undefined) {
return clone(this.account)
}
return this.sendRequest({ method: 'getAccount', params: [] })
}