ssh2-sftp-client: client sftp exists crash
when i call exists function with path folder not existing. i have error :
stack:"Error: sftp.exists: sftp.realPath:
Cannot find message [/Inbox/tip/test] /Inbox/tip/test\n
at formatError (\node_modules\ssh2-sftp-client\src\index.js:56:10)\n
at SftpClient.exists (\node_modules\ssh2-sftp-client\src\index.js:241:27)\n
at process._tickCallback (internal/process/next_tick.js:68:7)"
my code :
clientSftp.connect({
host: ssh2.host,
port: ssh2.port,
username: ssh2.username,
password: ssh2.password
}) .then(() => {
const folder = `${ssh2.path}/${type}`;
return clientSftp.exists(folder);
}) .then((exist) => {
return resolve(exist);
}).catch(err => {
self.logger.error( `transport to ${localFile}/${remoteFile} error`+ err.message);
return reject(err);
});
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (8 by maintainers)
Odd, I added a comment about fixing this 5 days ago and now it is not there!
Anyway, I think your analysis was correct and I have fixed the catch test to use the error code rather than the message, so this issue should now be resolved. This change to add error.code properties in a consistent manner was already undeway (since node v10 improved this situation).
I have released a new version (v4.3.0) which has these fixes included.