Skip to content

Commit 6830ba3

Browse files
committed
🤖 debug: add exit/output logging to LocalBaseRuntime.exec
1 parent 6171fef commit 6830ba3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/node/runtime/LocalBaseRuntime.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ export abstract class LocalBaseRuntime implements Runtime {
132132
let timedOut = false;
133133
let aborted = false;
134134

135+
// Debug: log raw stdout/stderr from the child process
136+
let debugStdout = "";
137+
let debugStderr = "";
138+
childProcess.stdout?.on("data", (chunk: Buffer) => {
139+
debugStdout += chunk.toString();
140+
});
141+
childProcess.stderr?.on("data", (chunk: Buffer) => {
142+
debugStderr += chunk.toString();
143+
});
144+
135145
// Create promises for exit code and duration
136146
// Uses special exit codes (EXIT_CODE_ABORTED, EXIT_CODE_TIMEOUT) for expected error conditions
137147
const exitCode = new Promise<number>((resolve, reject) => {
@@ -140,6 +150,12 @@ export abstract class LocalBaseRuntime implements Runtime {
140150
// which causes hangs when users spawn background processes like servers.
141151
// The 'exit' event fires when the main bash process exits, which is what we want.
142152
childProcess.on("exit", (code) => {
153+
log.info(`[LocalBaseRuntime.exec] Process exited with code: ${code}`);
154+
log.info(`[LocalBaseRuntime.exec] stdout length: ${debugStdout.length}`);
155+
log.info(`[LocalBaseRuntime.exec] stdout: ${debugStdout.substring(0, 500)}${debugStdout.length > 500 ? "..." : ""}`);
156+
if (debugStderr) {
157+
log.info(`[LocalBaseRuntime.exec] stderr: ${debugStderr.substring(0, 500)}${debugStderr.length > 500 ? "..." : ""}`);
158+
}
143159
// Clean up any background processes (process group cleanup)
144160
// This prevents zombie processes when scripts spawn background tasks
145161
if (childProcess.pid !== undefined) {

0 commit comments

Comments
 (0)