Skip to content

Commit accb21f

Browse files
committed
🤖 debug: add logging to execAsync to trace WSL command execution
1 parent e2e7f3f commit accb21f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/node/utils/disposableExec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { spawn } from "child_process";
22
import type { ChildProcess } from "child_process";
33
import { getPreferredSpawnConfig } from "@/node/utils/main/bashPath";
4+
import { log } from "@/node/services/log";
45

56
/**
67
* Disposable wrapper for child processes that ensures immediate cleanup.
@@ -130,11 +131,20 @@ export function execAsync(command: string): DisposableExec {
130131
// Wrap command in bash -c for consistent cross-platform behavior
131132
// For WSL, this also translates Windows paths to /mnt/... format
132133
const { command: bashCmd, args } = getPreferredSpawnConfig(command);
134+
135+
// Debug logging for Windows WSL issues
136+
log.info(`[execAsync] Original command: ${command}`);
137+
log.info(`[execAsync] Spawn command: ${bashCmd}`);
138+
log.info(`[execAsync] Spawn args: ${JSON.stringify(args)}`);
139+
133140
const child = spawn(bashCmd, args, {
134141
stdio: ["ignore", "pipe", "pipe"],
135142
// Prevent console window from appearing on Windows
136143
windowsHide: true,
137144
});
145+
146+
log.info(`[execAsync] Spawned process PID: ${child.pid}`);
147+
138148
const promise = new Promise<{ stdout: string; stderr: string }>((resolve, reject) => {
139149
let stdout = "";
140150
let stderr = "";
@@ -153,9 +163,16 @@ export function execAsync(command: string): DisposableExec {
153163
child.on("exit", (code, signal) => {
154164
exitCode = code;
155165
exitSignal = signal;
166+
log.info(`[execAsync] Process exited with code: ${code}, signal: ${signal}`);
156167
});
157168

158169
child.on("close", () => {
170+
log.info(`[execAsync] Process closed. stdout length: ${stdout.length}, stderr length: ${stderr.length}`);
171+
log.info(`[execAsync] stdout: ${stdout.substring(0, 500)}${stdout.length > 500 ? "..." : ""}`);
172+
if (stderr) {
173+
log.info(`[execAsync] stderr: ${stderr.substring(0, 500)}${stderr.length > 500 ? "..." : ""}`);
174+
}
175+
159176
// Only resolve if process exited cleanly (code 0, no signal)
160177
if (exitCode === 0 && exitSignal === null) {
161178
resolve({ stdout, stderr });

0 commit comments

Comments
 (0)