Capture both stdout and stderr from execa-spawned processes (#3073)

This commit is contained in:
Chris Estreich 2025-04-30 12:49:48 -07:00 committed by GitHub
parent b51abf70f9
commit 49382b7d89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 4 deletions

View file

@ -0,0 +1,5 @@
---
"roo-cline": patch
---
Capture stderr in execa-spawned processes

View file

@ -38,13 +38,14 @@ export class ExecaTerminalProcess extends BaseTerminalProcess {
shell: true,
cwd: this.terminal.getCurrentWorkingDirectory(),
cancelSignal: this.controller.signal,
all: true,
})`${command}`
this.terminal.setActiveStream(subprocess, subprocess.pid)
this.emit("line", "")
const stream = subprocess.iterable({ from: "all", preserveNewlines: true })
this.terminal.setActiveStream(stream, subprocess.pid)
for await (const line of subprocess) {
this.fullOutput += `${line}\n`
for await (const line of stream) {
this.fullOutput += line
const now = Date.now()
@ -62,6 +63,9 @@ export class ExecaTerminalProcess extends BaseTerminalProcess {
console.error(`[ExecaTerminalProcess] shell execution error: ${error.message}`)
this.emit("shell_execution_complete", { exitCode: error.exitCode ?? 0, signalName: error.signal })
} else {
console.error(
`[ExecaTerminalProcess] shell execution error: ${error instanceof Error ? error.message : String(error)}`,
)
this.emit("shell_execution_complete", { exitCode: 1 })
}
}