Repository navigation
Conversation
…r's close Since Node 14, Duplex streams default to autoDestroy, which destroys the stream once both its readable and writable sides have ended. Channel's destroy() sends CHANNEL_CLOSE, so a client channel was closed as soon as the server's EOF arrived after the client ended its side, despite allowHalfOpen. A server may send exit-status after its EOF (OpenSSH does when the command's output closes before it is reaped); that status was then lost and 'exit' never fired, with 'close' getting no code. This is the same Node 14 change already handled for the SFTP streams.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since Node 14,
Duplexstreams default toautoDestroy: true: once both the readable and the writable side have ended, the stream is destroyed.Channel#destroy()callsclose(), so a client channel sendsCHANNEL_CLOSEas soon as both of these have happened:stream.end(stdin)on an exec channel), andThat happens even though the channel is half-open (
allowHalfOpen), andonFinishdeliberately sends only EOF.A server may send
exit-statusafter its EOF. OpenSSH does this whenever the command's output closes before the command has been reaped. Once the client has closed the channel, nothing more can be delivered, so the exit status is lost:'exit'never fires and'close'gets no code. Over a fast link this happens intermittently in practice: a few percent of short commands ended with no exit code.This passes
autoDestroy: falseinChannel's stream options, the same fix #1009 made for the SFTP read and write streams. The channel then ends with the server'sCHANNEL_CLOSE, which ssh2 already answers, or an explicitclose()ordestroy().The new test in
test/test-exec.jshas a server send data and EOF, then the exit status 100 ms later. It fails without the change (Wrong close args: [ undefined ]) and passes with it. The rest of the suite is unchanged; locally only the OpenSSH integration test for old RSA keys fails, with and without this change.