fix(core): some dumb null checks

This commit is contained in:
alina 🌸 2023-11-17 18:09:35 +03:00
parent a0a22554cb
commit 0d3c18b885
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI
2 changed files with 5 additions and 4 deletions

View file

@ -1771,7 +1771,6 @@ export class SessionConnection extends PersistentConnection {
}
const result = writer.result()
// probably the easiest way lol
this.log.debug(
'sending %d messages: size = %db, acks = %d (msg_id = %s), ping = %s (msg_id = %s), state_req = %s (msg_id = %s), resend = %s (msg_id = %s), cancels = %s (msg_id = %s), rpc = %s, container = %s, root msg_id = %l',
@ -1800,7 +1799,9 @@ export class SessionConnection extends PersistentConnection {
if (ackMsgIds) {
this._session.queuedAcks.splice(0, 0, ...ackMsgIds)
}
this._onMessageFailed(rootMsgId!, 'unknown error')
if (rootMsgId) {
this._onMessageFailed(rootMsgId, 'unknown error')
}
})
}
}

View file

@ -116,12 +116,12 @@ export abstract class BaseTcpTransport extends EventEmitter implements ITelegram
}
async send(bytes: Uint8Array): Promise<void> {
const framed = await this._packetCodec.encode(bytes)
if (this._state !== TransportState.Ready) {
throw new MtcuteError('Transport is not READY')
}
const framed = await this._packetCodec.encode(bytes)
return new Promise((resolve, reject) => {
this._socket!.write(framed, (error) => {
if (error) {