我用ssh2-sftp客户端来获取一些文件。如果我使用sftp.end();最后在控制台中得到这个错误:
{ 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'
...我遗漏了什么?
发布于 2020-06-10 19:44:50
我认为当前发生的情况是,由于您没有从第二个then()返回一个then(),第三个then()将立即被解析(值为undefined),这将导致您的连接立即被终止(在fastGet()有时间完成之前)。
要解决这个问题,您需要从第二个Promise中显式返回一个只在所有文件被传输后才能被解析的then()。如果至少有一个转让失败,您也可以考虑拒绝该承诺。
https://stackoverflow.com/questions/62309198
复制相似问题