fix(core): properly handle resending of pending rpc calls
This commit is contained in:
parent
2034ae8b28
commit
f4c0c1bd31
1 changed files with 7 additions and 6 deletions
|
@ -177,6 +177,8 @@ export class TelegramConnection extends PersistentConnection {
|
||||||
this._sendOnceUsable = []
|
this._sendOnceUsable = []
|
||||||
sendOnceUsable.forEach((it) => this._resend(it))
|
sendOnceUsable.forEach((it) => this._resend(it))
|
||||||
|
|
||||||
|
Object.entries(this._pendingRpcCalls).forEach(([id, it]) => this._resend(it, id))
|
||||||
|
|
||||||
this._pingInterval = setInterval(() => {
|
this._pingInterval = setInterval(() => {
|
||||||
if (this._pendingPing === null) {
|
if (this._pendingPing === null) {
|
||||||
this._pendingPing = ulongToLong(
|
this._pendingPing = ulongToLong(
|
||||||
|
@ -221,9 +223,10 @@ export class TelegramConnection extends PersistentConnection {
|
||||||
this._sendPendingAcks()
|
this._sendPendingAcks()
|
||||||
}
|
}
|
||||||
|
|
||||||
private _resend(it: PendingMessage): void {
|
private _resend(it: PendingMessage, id?: string): void {
|
||||||
debug('resending %s', it.method)
|
debug('resending %s', it.method)
|
||||||
this._sendBufferForResult(it).catch(it.promise.reject)
|
this._sendBufferForResult(it).catch(it.promise.reject)
|
||||||
|
if (id) delete this._pendingRpcCalls[id]
|
||||||
}
|
}
|
||||||
|
|
||||||
private _authorize(): void {
|
private _authorize(): void {
|
||||||
|
@ -344,8 +347,7 @@ export class TelegramConnection extends PersistentConnection {
|
||||||
this._mtproto.serverSalt = message.newServerSalt
|
this._mtproto.serverSalt = message.newServerSalt
|
||||||
|
|
||||||
if (this._pendingRpcCalls[badMsgId]) {
|
if (this._pendingRpcCalls[badMsgId]) {
|
||||||
this._resend(this._pendingRpcCalls[badMsgId])
|
this._resend(this._pendingRpcCalls[badMsgId], badMsgId)
|
||||||
delete this._pendingRpcCalls[badMsgId] // because resend will assign it a new id
|
|
||||||
} else if (
|
} else if (
|
||||||
this._pendingPingMsgId &&
|
this._pendingPingMsgId &&
|
||||||
this._pendingPingMsgId.eq(message.badMsgId)
|
this._pendingPingMsgId.eq(message.badMsgId)
|
||||||
|
@ -389,8 +391,7 @@ export class TelegramConnection extends PersistentConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._pendingRpcCalls[badMsgId]) {
|
if (this._pendingRpcCalls[badMsgId]) {
|
||||||
this._resend(this._pendingRpcCalls[badMsgId])
|
this._resend(this._pendingRpcCalls[badMsgId], badMsgId)
|
||||||
delete this._pendingRpcCalls[badMsgId] // because resend will assign it a new id
|
|
||||||
} else {
|
} else {
|
||||||
debug('bad_msg_notification to unknown message %s', badMsgId)
|
debug('bad_msg_notification to unknown message %s', badMsgId)
|
||||||
}
|
}
|
||||||
|
@ -422,7 +423,7 @@ export class TelegramConnection extends PersistentConnection {
|
||||||
msgId > firstMsgIdStr) ||
|
msgId > firstMsgIdStr) ||
|
||||||
firstMsgId.lt(bigInt(msgId, 16))
|
firstMsgId.lt(bigInt(msgId, 16))
|
||||||
) {
|
) {
|
||||||
this._resend(info)
|
this._resend(info, msgId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue