chore(core): improved logging

This commit is contained in:
alina 🌸 2024-06-25 00:09:00 +03:00
parent 85f6610e09
commit a7c7a636cd
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI
2 changed files with 6 additions and 0 deletions

View file

@ -360,6 +360,8 @@ export class MtClient extends EventEmitter {
* Close all connections and finalize the client.
*/
async close(): Promise<void> {
this.log.debug('closing client')
this._config.destroy()
await this.network.destroy()
@ -369,6 +371,8 @@ export class MtClient extends EventEmitter {
this._prepare.reset()
this._connect.reset()
this._abortController.abort()
this.log.debug('client closed successfully')
}
/**

View file

@ -200,6 +200,7 @@ export class MtprotoSession {
if (!keepPending) {
for (const info of this.pendingMessages.values()) {
if (info._ === 'rpc') {
this.log.debug('rejecting pending rpc %s', info.rpc.method)
info.rpc.promise.reject(new MtcuteError('Session is reset'))
}
}
@ -214,6 +215,7 @@ export class MtprotoSession {
const rpc = this.queuedRpc.popFront()!
if (rpc.sent === false) {
this.log.debug('rejecting pending rpc %s', rpc.method)
rpc.promise.reject(new MtcuteError('Session is reset'))
}
}