mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-11 11:10:13 +01:00
fix(gbrain-detect): ignore doctor stderr so a chatty doctor cannot overflow the spawn buffer
stderr over spawnSync's 1 MB maxBuffer made the call fail with ENOBUFS and dropped the stdout report, turning a healthy brain into a Step 5 STOP. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
077d70fec9
commit
1dc99d8925
1 file changed
+6
-6
@@ -147,7 +147,10 @@ interface DoctorVerdict {
|
||||
function runDoctor(extraArgs: string[], timeoutMs: number): DoctorVerdict {
|
||||
let r: ReturnType<typeof spawnGbrain>;
|
||||
try {
|
||||
r = spawnGbrain(["doctor", "--json", ...extraArgs, "--scope=brain"], { timeout: timeoutMs });
|
||||
r = spawnGbrain(["doctor", "--json", ...extraArgs, "--scope=brain"], {
|
||||
timeout: timeoutMs,
|
||||
stdio: ["ignore", "pipe", "ignore"],
|
||||
});
|
||||
} catch (e) {
|
||||
const error = `gbrain doctor could not start: ${e instanceof Error ? e.message : String(e)}`;
|
||||
return { brain_ok: false, status: null, brain_failures: [], skill_failures: [], report: null, error };
|
||||
@@ -158,11 +161,8 @@ function runDoctor(extraArgs: string[], timeoutMs: number): DoctorVerdict {
|
||||
} catch {}
|
||||
if (!report || typeof report !== "object") {
|
||||
const cause = r.error ? r.error.message : r.signal ? `killed by ${r.signal}` : `exit ${r.status}`;
|
||||
const stderr = (r.stderr || "").trim().split("\n").slice(-5).join("\n");
|
||||
return {
|
||||
brain_ok: false, status: null, brain_failures: [], skill_failures: [], report: null,
|
||||
error: `gbrain doctor printed no JSON report (${cause})${stderr ? `: ${stderr}` : ""}`,
|
||||
};
|
||||
const error = `gbrain doctor printed no JSON report (${cause})`;
|
||||
return { brain_ok: false, status: null, brain_failures: [], skill_failures: [], report: null, error };
|
||||
}
|
||||
const failed = (Array.isArray(report.checks) ? report.checks : []).filter((c) => c?.status === "fail");
|
||||
const skill_failures = failed.filter((c) => c.category === "skill").map((c) => c.name ?? "unnamed");
|
||||
|
||||
Reference in new issue
Block a user