From 0b8500068ab09ac957c88f242a4aaf1b3c810cad Mon Sep 17 00:00:00 2001 From: Keith Date: Fri, 19 Nov 2021 19:14:53 -0500 Subject: [PATCH 1/2] protocol/SFTP: Manual error emit on write error when autoClose = true. --- lib/protocol/SFTP.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/protocol/SFTP.js b/lib/protocol/SFTP.js index b10d9e53..874b7f2e 100644 --- a/lib/protocol/SFTP.js +++ b/lib/protocol/SFTP.js @@ -3695,8 +3695,10 @@ WriteStream.prototype._write = function(data, encoding, cb) { this.pos, (er, bytes) => { if (er) { - if (this.autoClose) + if (this.autoClose) { + this.emit('error', er); // er is swalloed by destroy(), emit manually. this.destroy(); + } return cb(er); } this.bytesWritten += bytes; From 94429bb38b73e5268631655777f97e6d3856c4e9 Mon Sep 17 00:00:00 2001 From: Keith Date: Tue, 28 Dec 2021 19:00:12 -0500 Subject: [PATCH 2/2] protocol/SFTP: Passing error to destroy when closing when autoClose = true. --- lib/protocol/SFTP.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/protocol/SFTP.js b/lib/protocol/SFTP.js index 874b7f2e..37f1e895 100644 --- a/lib/protocol/SFTP.js +++ b/lib/protocol/SFTP.js @@ -3695,10 +3695,8 @@ WriteStream.prototype._write = function(data, encoding, cb) { this.pos, (er, bytes) => { if (er) { - if (this.autoClose) { - this.emit('error', er); // er is swalloed by destroy(), emit manually. - this.destroy(); - } + if (this.autoClose) + this.destroy(er); return cb(er); } this.bytesWritten += bytes;