Fix intermittent exit code capture failure in SSH executeCommand#11
Merged
jamesmurdza merged 2 commits intoSep 24, 2025
Merged
Conversation
Replace optional SSH2 'exit' event with command-level exit code capture by appending '; echo "EXIT_CODE:$?"' to commands and parsing from output. The SSH2 spec makes 'exit' events optional, causing intermittent fallback to exit code 0 for failed commands. - Append exit code capture to all foreground commands - Parse exit code from last matching line in output - Remove exit code line from final output to keep it clean - Eliminates race condition with optional 'exit' event
Collaborator
Author
|
Made a new release with version |
Owner
|
All tests pass for me! |
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.
Problem
The
executeCommandmethod was intermittently returning exit code0for commands that should fail (e.g.,nonexistentcommand12345should return127). This happened because we were relying on the SSH2exitevent, which is optional according to the SSH2 specification.Test Case That Was Failing
Root Cause
exitevents are optional per the specificationexitevent doesn't fire, we were falling back to exit code0Solution
Stop relying on optional SSH2 events and capture exit codes at the command level:
${command}; echo "EXIT_CODE:$?"EXIT_CODE:Testing
Impact