From 1dc99d8925ee77ea1098df65ed9f7c3b5a9c8622 Mon Sep 17 00:00:00 2001 From: garrytan Date: Sun, 1 Nov 2026 14:31:25 +0000 Subject: [PATCH] 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> --- bin/gstack-gbrain-detect | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/gstack-gbrain-detect b/bin/gstack-gbrain-detect index 2ad615e1a..00f98a9c2 100755 --- a/bin/gstack-gbrain-detect +++ b/bin/gstack-gbrain-detect @@ -147,7 +147,10 @@ interface DoctorVerdict { function runDoctor(extraArgs: string[], timeoutMs: number): DoctorVerdict { let r: ReturnType; 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");