Browse Source

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

Chris Estreich 10 months ago
parent
commit
49382b7d89

+ 5 - 0
.changeset/fifty-pumpkins-wave.md

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

+ 8 - 4
src/integrations/terminal/ExecaTerminalProcess.ts

@@ -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 })
 			}
 		}