ssh2-streams icon indicating copy to clipboard operation
ssh2-streams copied to clipboard

Piping sftp readStream to sftp writeStream - no error when client disconnects

Open jeffrson opened this issue 5 years ago • 3 comments

Hi, I'm copying files via sftp from one server to another simply by piping a readStream to writeStream. Actually I'm using ssh2-promise, but afaict, it simply wraps ssh2-streams methods.

Unfortunately, it seems copying hangs forever, when (say) the destination server disappears. Debug output says

DEBUG: Outgoing: Writing CHANNEL_CLOSE (0) and later DEBUG: Outgoing: Writing REQUEST_FAILURE

every 15 seconds. When the source server disappears instead, I don't see a channel close, but outgoing write fails with the same DEBUG message.

Furthermore, when I want to cancel a copy task, closing ssh2 connection does not seem to stop/error the streams.

How should I handle these cases?

jeffrson avatar Mar 25 '19 10:03 jeffrson

Well, nevertheless it might be an ssh2-promise issue (see linked issue).

jeffrson avatar Mar 26 '19 16:03 jeffrson

Hmmm - is it a bug, that not the readStream emits the error, but SSH2.Client?

jeffrson avatar Mar 26 '19 17:03 jeffrson

If there are outstanding requests for an sftp session when it's cleaned up, errors are passed to the requests' callbacks, which should in turn emit errors on the stream.

mscdex avatar Mar 26 '19 18:03 mscdex