Originally from: realtymaps/promise-ftp#19
This exception is actually from promise-sftp library. However promise-sftp is not letting users create an issue.
Here is a code snippet to reproduce the error:
var PromiseSftp = require('promise-sftp');
function test() {
const ftp = new PromiseSftp();
return ftp.connect({
host: 'host.address',
user: 'username',
password: 'password',
port: 22,
})
.then(() => {
console.log('connected');
return ftp.put(Buffer.from('this is a test'), '/invalid/path/to/file.txt')
.then(() => {
console.log('successfully uploaded');
})
.catch(err => {
console.log('failed: ' + JSON.stringify(err));
});
})
.then(() => ftp.end())
.catch(err => {
console.log('ftp end error: ' + JSON.stringify(err));
});
}
Since the path does not exist on the ftp server, the promise should be rejected. It is resolving successfully and throwing an error when we attempt to end the connection.
Output:
connected
successfully uploaded
events.js:160
throw er; // Unhandled 'error' event
Error: No such file
at SFTPStream._transform (~\node_modules\ssh2-streams\lib\sftp.js:405:27)
at SFTPStream.Transform._read (_stream_transform.js:167:10)
at SFTPStream._read (~\node_modules\ssh2-streams\lib\sftp.js:181:15)
at SFTPStream.Transform._write (_stream_transform.js:155:12)
at doWrite (_stream_writable.js:334:12)
at writeOrBuffer (_stream_writable.js:320:5)
at SFTPStream.Writable.write (_stream_writable.js:247:11)
at Channel.ondata (_stream_readable.js:555:20)
at emitOne (events.js:96:13)
at Channel.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Channel.Readable.push (_stream_readable.js:134:10)
at SSH2Stream.<anonymous> (~\node_modules\ssh2\lib\Channel.js:166:15)
at emitOne (events.js:96:13)
at SSH2Stream.emit (events.js:188:7)
at parsePacket (~\node_modules\ssh2-streams\lib\ssh.js:3439:10)
at SSH2Stream._transform (~\node_modules\ssh2-streams\lib\ssh.js:667:13)
at SSH2Stream.Transform._read (_stream_transform.js:167:10)
at SSH2Stream._read (~\node_modules\ssh2-streams\lib\ssh.js:251:15)
at SSH2Stream.Transform._write (_stream_transform.js:155:12)
at doWrite (_stream_writable.js:334:12)
at writeOrBuffer (_stream_writable.js:320:5)
Originally from: realtymaps/promise-ftp#19
This exception is actually from promise-sftp library. However promise-sftp is not letting users create an issue.
Here is a code snippet to reproduce the error:
Since the path does not exist on the ftp server, the promise should be rejected. It is resolving successfully and throwing an error when we attempt to end the connection.
Output: