Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

fix: correctly report exit codes from ExecaTerminalProcess - #11045

Draft
ghost wants to merge 1 commit into
mainfrom
fix/execa-terminal-exit-code-11044
Draft

fix: correctly report exit codes from ExecaTerminalProcess#11045
ghost wants to merge 1 commit into
mainfrom
fix/execa-terminal-exit-code-11044

Conversation

@ghost

@ghost ghost commented Jan 28, 2026

Copy link
Copy Markdown

Related GitHub Issue

Closes: #11044

Description

This PR attempts to address Issue #11044 where Roo Code was not getting the correct return code from commands running in the VSCode terminal.

Root Cause: In ExecaTerminalProcess.ts, after iterating over the subprocess output stream, the code always emitted exitCode: 0 regardless of the actual exit code. The problem is that stream iteration completes successfully regardless of the exit code - the subprocess needs to be awaited separately to obtain the actual exit code.

Solution: After the stream iteration completes, await the subprocess to get its result and emit the correct exit code. Handle edge cases where awaiting the subprocess might throw an ExecaError.

Key changes:

  • After stream iteration, await this.subprocess to get the actual exit code
  • Handle ExecaError that may be thrown during the await
  • Emit the correct exit code and signal information

Test Procedure

  1. Added new tests in ExecaTerminalProcess.spec.ts:

    • Test for non-zero exit code (exit 1)
    • Test for specific exit codes (e.g., 127 for command not found)
    • Test for ExecaError with signal handling
    • Test for successful commands (exit 0)
  2. All 15 tests pass:

    npx vitest run integrations/terminal/__tests__/ExecaTerminalProcess.spec.ts
    
  3. Manual testing: Commands like false or exit 1 should now report the correct non-zero exit code.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes.
  • Documentation Impact: No documentation updates are required.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

Additional Notes

Feedback and guidance are welcome!


Important

Fixes exit code reporting in ExecaTerminalProcess by awaiting subprocess and handling ExecaError.

  • Behavior:
    • In ExecaTerminalProcess.ts, await this.subprocess after stream iteration to get the correct exit code.
    • Handle ExecaError during await to emit correct exit code and signal.
  • Tests:
    • Add tests in ExecaTerminalProcess.spec.ts for non-zero exit codes, specific exit codes, ExecaError handling, and successful commands.
    • Verify correct exit code emission for commands like exit 1, nonexistent_command, and echo success.

This description was created by Ellipsis for 97f0aca. You can customize this summary. It will automatically update as commits are pushed.

- Fix bug where ExecaTerminalProcess always emitted exitCode: 0
- After stream iteration, await subprocess to get actual exit code
- Handle ExecaError thrown during await with exit code and signal
- Add tests for non-zero exit code scenarios

Fixes #11044
@ghost

ghost commented Jan 28, 2026

Copy link
Copy Markdown
Author

Rooviewer Clock   See task on Roo Cloud

Review completed. No issues found.

The fix correctly addresses the bug where ExecaTerminalProcess always emitted exitCode: 0 regardless of the actual command result. The implementation properly awaits the subprocess to capture the real exit code and handles ExecaError appropriately.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

No open projects
Status: Triage

Development

Successfully merging this pull request may close these issues.

[BUG] Roo Code CANNOT get the correct return code from commands running in vscode terminal

1 participant