Skip to content

Commit

Permalink
fix #119 race condition
Browse files Browse the repository at this point in the history
ack should wait for readline to finish
  • Loading branch information
ChiChou committed Jun 30, 2023
1 parent 578d711 commit 5c9ff78
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/scp.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ class SCPReceiver extends Duplex {
if (chunk[chunk.length - 1] !== 0x0A)
return callback(new Error('Invalid protocol, expect \\n'));

this.#handleLine(chunk.toString().trimEnd());
this.#ack();
this.#handleLine(chunk.toString().trimEnd())
.then(() => this.#ack());
} else if (this.#state == State.Data) {
if (!this.output)
return callback(new Error('Invalid state'));
Expand Down

0 comments on commit 5c9ff78

Please sign in to comment.