fix(core): hopefully fix duplicating msg_id leading to bad_msg_container 64
This commit is contained in:
parent
e20bc02a0b
commit
9091a10537
2 changed files with 8 additions and 3 deletions
|
@ -170,6 +170,7 @@ export class MtprotoSession {
|
|||
}
|
||||
|
||||
updateTimeOffset(offset: number) {
|
||||
this.log.debug('time offset updated: %d', offset)
|
||||
this._timeOffset = offset
|
||||
// lastMessageId was generated with (potentially) wrong time
|
||||
// reset it to avoid bigger issues - at worst, we'll get bad_msg_notification
|
||||
|
@ -243,7 +244,7 @@ export class MtprotoSession {
|
|||
|
||||
let messageId = new Long((timeMSec << 21) | (random << 3) | 4, timeSec)
|
||||
|
||||
if (this._lastMessageId.gt(messageId)) {
|
||||
if (this._lastMessageId.ge(messageId)) {
|
||||
messageId = this._lastMessageId.add(4)
|
||||
}
|
||||
|
||||
|
|
|
@ -954,9 +954,10 @@ export class SessionConnection extends PersistentConnection {
|
|||
private _onAllFailed(reason: string) {
|
||||
// called when all the pending messages are to be resent
|
||||
// e.g. when server returns 429
|
||||
|
||||
// most service messages can be omitted as stale
|
||||
|
||||
this.log.debug('all messages failed because of %s', reason)
|
||||
|
||||
for (const msgId of this._session.pendingMessages.keys()) {
|
||||
const info = this._session.pendingMessages.get(msgId)!
|
||||
|
||||
|
@ -966,6 +967,7 @@ export class SessionConnection extends PersistentConnection {
|
|||
case 'resend':
|
||||
case 'ping':
|
||||
// no longer relevant
|
||||
this.log.debug('forgetting about %s message %l', info._, msgId)
|
||||
this._session.pendingMessages.delete(msgId)
|
||||
break
|
||||
default:
|
||||
|
@ -1949,10 +1951,12 @@ export class SessionConnection extends PersistentConnection {
|
|||
packetSize = writer.pos
|
||||
|
||||
const containerId = this._session.getMessageId()
|
||||
const seqNo = this._session.getSeqNo(false)
|
||||
this.log.debug('container: msg_id assigned %l, seqno: %d', containerId, seqNo)
|
||||
writer.pos = 0
|
||||
rootMsgId = containerId
|
||||
writer.long(this._registerOutgoingMsgId(containerId))
|
||||
writer.uint(this._session.getSeqNo(false))
|
||||
writer.uint(seqNo)
|
||||
writer.uint(packetSize - 16)
|
||||
writer.pos = packetSize
|
||||
|
||||
|
|
Loading…
Reference in a new issue