Hmbown/CodeWhale · error · ExecError
exited
Error message
${cmd} exited ${r.code}: ${trim(r.stderr || r.stdout)} What it means
runOk converts a non-zero child exit code into this ExecError containing the command, exit code, and trimmed stderr (or stdout as fallback). Unlike the timeout case, the process ran and finished but reported failure. The full run result is attached to the error for diagnosis.
Solutions
- Read e.message / e.result.stderr for the root cause string emitted by the command.
- Fix the underlying failure it reports (read-only element, missing file, permission) before retrying.
- Run the same command manually in a shell to reproduce and inspect the full stderr.
- Check PowerShell execution policy and module availability if the failure is a policy or cmdlet-not-found error.
Example fix
// before
await runOk('powershell', ['-Command', script]);
// after
try {
await runOk('powershell', ['-Command', script], { timeoutMs: 30000 });
} catch (e) {
const detail = e.result?.stderr || e.result?.stdout || '';
throw new Error(`automation step failed: ${detail}`); // surface real cause
} Defensive patterns
Strategy: try-catch
Type guard
const isExitCodeError = (e) => e instanceof Error && / exited \d+: /.test(e.message) && e.result != null;
Try / catch
try {
return await runOk(cmd, args, opts);
} catch (e) {
if (isExitCodeError(e)) {
const cause = (e.result.stderr || e.result.stdout || '').trim();
throw new Error(`${cmd} failed (${e.message.match(/ exited (\d+)/)?.[1]}): ${cause}`);
}
throw e;
} Prevention
- Always inspect e.result.stderr/stdout before retrying a failed command.
- Check PowerShell execution policy and module availability in target environments.
- Reproduce failing commands manually to see full diagnostics.
- Validate arguments and file paths before spawning the process.
When it happens
Trigger: Any runOk-invoked command exiting non-zero: PowerShell script exceptions (thrown strings like 'element_read_only'), missing executables or modules, access-denied on files, or scripts that Write-Output an error JSON and exit 1.
Common situations: PowerShell execution policy blocking scripts; a UIA action failing inside the script; a required Windows feature/assembly missing; invalid arguments causing the command itself to fail fast.
Related errors
- Cloud agent harness exited with code
- Command failed with exit code
- dsh exited with status
- Failed to run command
- git failed
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/cfa87aa20ee30502.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/plugins/computer-use/src/exec.mjs:157
});
child.stdin.write(JSON.stringify(message) + "\n");
return await Promise.race([next, cancelled, new Promise((_, reject) => { commandTimer = setTimeout(() => reject(new ExecError("Native input owner did not acknowledge pointer motion")), opts.timeoutMs ?? 20_000); })]);
}
catch (error) { await release().catch(() => {}); throw error; }
finally { clearTimeout(commandTimer); signal?.removeEventListener("abort", abort); }
} };
} catch (error) {
await release().catch(() => {});
throw error;
} finally { clearTimeout(timer); }
}
/** run() and throw a typed error on non-zero exit / timeout. */
export async function runOk(cmd, args = [], opts = {}) {
const r = await run(cmd, args, opts);
if (r.aborted) throw Object.assign(new ExecError("computer request cancelled", r), { code: "cancelled" });
if (r.timedOut) throw new ExecError(`timeout after ${opts.timeoutMs ?? 20_000}ms: ${cmd}`, r);
if (r.code !== 0) throw new ExecError(`${cmd} exited ${r.code}: ${trim(r.stderr || r.stdout)}`, r);
return r;
}
export class ExecError extends Error {
constructor(message, result) {
super(message);
this.name = "ExecError";
this.result = result;
}
}
/** True when the executable exists on PATH (or opts.fullPath exists). */
export async function have(cmd) {
const probe = process.platform === "win32" ? "where" : "which";
const r = await run(probe, [cmd], { timeoutMs: 5000 });
return r.code === 0 && r.stdout.trim().length > 0;
}
View on GitHub (pinned to 73e0f67d83)