feat(core): support rpc timeouts (for real)
This commit is contained in:
parent
c092347b63
commit
b4f731d831
1 changed files with 8 additions and 0 deletions
|
@ -236,6 +236,7 @@ export class TelegramConnection extends PersistentConnection {
|
||||||
private _resend(it: PendingMessage, id?: string): 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 (it.cancel) clearTimeout(it.cancel)
|
||||||
if (id) delete this._pendingRpcCalls[id]
|
if (id) delete this._pendingRpcCalls[id]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,6 +614,13 @@ export class TelegramConnection extends PersistentConnection {
|
||||||
pending.cancel = setTimeout(() => {
|
pending.cancel = setTimeout(() => {
|
||||||
const pending = this._pendingRpcCalls[messageIdStr]
|
const pending = this._pendingRpcCalls[messageIdStr]
|
||||||
if (pending) {
|
if (pending) {
|
||||||
|
this.sendEncryptedMessage({
|
||||||
|
_: 'mt_rpcDropAnswer',
|
||||||
|
reqMsgId: messageId,
|
||||||
|
}).catch(() => {
|
||||||
|
/* no-op */
|
||||||
|
})
|
||||||
|
|
||||||
const error = new RpcTimeoutError(timeout)
|
const error = new RpcTimeoutError(timeout)
|
||||||
if (this.params.niceStacks !== false) {
|
if (this.params.niceStacks !== false) {
|
||||||
makeNiceStack(error, pending.stack!, pending.method)
|
makeNiceStack(error, pending.stack!, pending.method)
|
||||||
|
|
Loading…
Reference in a new issue