Skip to content

Commit

Permalink
fix: Fix end() method on async write()
Browse files Browse the repository at this point in the history
  • Loading branch information
Rapsssito committed Jun 14, 2020
1 parent 2418cf6 commit a1a0771
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/TcpSocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,15 @@ export default class TcpSocket {
*/
end(data, encoding) {
if (this._destroyed) return;
if (data) this.write(data, encoding);
this._destroyed = true;
Sockets.end(this._id);
if (data) {
this.write(data, encoding, () => {
this._destroyed = true;
Sockets.end(this._id);
});
} else {
this._destroyed = true;
Sockets.end(this._id);
}
}

destroy() {
Expand Down

0 comments on commit a1a0771

Please sign in to comment.