Skip to content

protocol/SFTP: Manual error emit on write error when autoClose = true. #1091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/protocol/SFTP.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just instead do something like:

Suggested change
this.destroy();
this.destroy(er);

that should have the same effect.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thank you. I've updated the branch and tested.

}
return cb(er);
}
this.bytesWritten += bytes;
Expand Down