最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Node.js - ssh2-sftp-client getting multiple files error - Stack Overflow

programmeradmin0浏览0评论

I use ssh2-sftp-client to get some files. If I use sftp.end(); at the end I get this error in the console:

{ Error: fastGet->exists->exists: No SFTP connection available
    at Object.formatError (/home/project/node_modules/ssh2-sftp-client/src/utils.js:62:18)
    at SftpClient.fastGet (/home/project/node_modules/ssh2-sftp-client/src/index.js:590:19)
    at process._tickCallback (internal/process/next_tick.js:68:7) code: 'ERR_NOT_CONNECTED', custom: true } 'Error'

...

What am I missing?

I use ssh2-sftp-client to get some files. If I use sftp.end(); at the end I get this error in the console:

{ Error: fastGet->exists->exists: No SFTP connection available
    at Object.formatError (/home/project/node_modules/ssh2-sftp-client/src/utils.js:62:18)
    at SftpClient.fastGet (/home/project/node_modules/ssh2-sftp-client/src/index.js:590:19)
    at process._tickCallback (internal/process/next_tick.js:68:7) code: 'ERR_NOT_CONNECTED', custom: true } 'Error'

...

What am I missing?

Share Improve this question edited Jun 11, 2020 at 17:55 Philipp M asked Jun 10, 2020 at 17:06 Philipp MPhilipp M 3,5085 gold badges43 silver badges101 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

What I believe is currently happening is that since you're not returning a Promise from your second then(), the third then() gets resolved immediately (with a value of undefined), which causes your connection to get terminated immediately (before your fastGet()s have time to finish).

To fix this, you would need to explicitly return a Promise from your second then() that only gets resolved once all of the files have been transferred. You may also want to consider rejecting that promise if at least one of the transfers fails.

发布评论

评论列表(0)

  1. 暂无评论