Skip to content

Commit c6e738c

Browse files
harlentanhaiyan.tan
authored andcommitted
fix: fix memory leak after writing data with false result
1 parent f458f6a commit c6e738c

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/adb/connection.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ export default class Connection extends EventEmitter {
7878
return this;
7979
}
8080

81-
public write(data: Buffer, callback?: (err?: Error) => void): this {
82-
this.socket.write(dump(data), callback);
83-
return this;
81+
public write(data: Buffer, callback?: (err?: Error) => void): boolean {
82+
return this.socket.write(dump(data), callback);
8483
}
8584

8685
public startServer(): Bluebird<ChildProcess> {

src/adb/sync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export default class Sync extends EventEmitter {
188188
const track = () => transfer.pop();
189189
const writeNext = () => {
190190
let chunk: Buffer;
191-
if ((chunk = stream.read(DATA_MAX_LENGTH) || stream.read())) {
191+
if (!this.connection.socket.writableNeedDrain && (chunk = stream.read(DATA_MAX_LENGTH) || stream.read())) {
192192
this._sendCommandWithLength(Protocol.DATA, chunk.length);
193193
transfer.push(chunk.length);
194194
if (this.connection.write(chunk, track)) {

0 commit comments

Comments
 (0)