[Perf] GramJs: Fix memory leaks (#1546)

This commit is contained in:
Alexander Zinchuk 2021-11-17 17:49:41 +03:00
parent 03b8698856
commit a31aa31b6b
2 changed files with 6 additions and 4 deletions

View File

@ -1,6 +1,6 @@
const MessageContainer = require('../tl/core/MessageContainer');
const TLMessage = require('../tl/core/TLMessage');
const BinaryWriter = require('../extensions/BinaryWriter');
const BinaryWriter = require('./BinaryWriter');
const USE_INVOKE_AFTER_WITH = [
'messages.SendMessage', 'messages.SendMedia', 'messages.SendMultiMedia',
@ -35,11 +35,10 @@ class MessagePacker {
}
}
this._queue.push(state);
this.setReady(true);
if (state) {
// 1658238041=MsgsAck, we don't care about MsgsAck here because they never resolve anyway.
if (state && state.request.CONSTRUCTOR_ID !== 1658238041) {
this._pendingStates.push(state);
state.promise
// Using finally causes triggering `unhandledrejection` event

View File

@ -338,6 +338,9 @@ class MTProtoSender {
const ack = new RequestState(new MsgsAck({ msgIds: Array(...this._pending_ack) }));
this._send_queue.append(ack);
this._last_acks.push(ack);
if (this._last_acks.length >= 10) {
this._last_acks.shift();
}
this._pending_ack.clear();
}
this._log.debug(`Waiting for messages to send...${this._reconnecting}`);