UnhandledPromiseRejectionWarning
Hello ! First of all I want to tell you that I love your module! Here is the mistake I come across:
(node:20550) UnhandledPromiseRejectionWarning: Error: (SSH) Channel open failure: open failed
at SSH2Stream.onFailure (/usr/src/app/node_modules/ssh2/lib/client.js:1205:13)
at Object.onceWrapper (events.js:421:26)
at SSH2Stream.emit (events.js:314:20)
at SSH2Stream.EventEmitter.emit (domain.js:486:12)
at parsePacket (/usr/src/app/node_modules/ssh2-streams/lib/ssh.js:3455:10)
at SSH2Stream._transform (/usr/src/app/node_modules/ssh2-streams/lib/ssh.js:701:13)
at SSH2Stream.Transform._read (_stream_transform.js:205:10)
at SSH2Stream._read (/usr/src/app/node_modules/ssh2-streams/lib/ssh.js:253:15)
at SSH2Stream.Transform._write (_stream_transform.js:193:12)
at writeOrBuffer (_stream_writable.js:352:12)
(node:20550) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 12)
I run an SSH command in a for loop in an asynchronous function and I don’t understand why I always have this error
With a catch for my async function, the returned error is :
Error: (SSH) Channel open failure: open failed
at SSH2Stream.onFailure (/usr/src/app/node_modules/ssh2/lib/client.js:1205:13)
at Object.onceWrapper (events.js:421:26)
at SSH2Stream.emit (events.js:314:20)
at SSH2Stream.EventEmitter.emit (domain.js:486:12)
at parsePacket (/usr/src/app/node_modules/ssh2-streams/lib/ssh.js:3455:10)
at SSH2Stream._transform (/usr/src/app/node_modules/ssh2-streams/lib/ssh.js:701:13)
at SSH2Stream.Transform._read (_stream_transform.js:205:10)
at SSH2Stream._read (/usr/src/app/node_modules/ssh2-streams/lib/ssh.js:253:15)
at SSH2Stream.Transform._write (_stream_transform.js:193:12)
at writeOrBuffer (_stream_writable.js:352:12) {
reason: 'ADMINISTRATIVELY_PROHIBITED',
lang: ''
}
Hello @dtouffut
Thanks for the report, this is quite an interesting error you got
Can you please share the code you used that led you to this error?
Thanks
@dtouffut My guess is that this exception happens when there is multiples ssh.putFile or when ssh.putDirectory is used.
I had trouble with these two cases, so I fixed with Promises and changed putDirectory function by a recursive checking for all files using fs then I sent each file to ssh.putFile and now all works fine.