Skip to content

Agent Mesh

fix(examples): guard gemini-buddy stdin against EPIPE crash

Tomas Tormof539d142fc0c
diff --git a/development/examples/gemini-buddy-mcp/buddy_server.mjs b/development/examples/gemini-buddy-mcp/buddy_server.mjs
index b55a5878..138538cf 100644
--- a/development/examples/gemini-buddy-mcp/buddy_server.mjs
+++ b/development/examples/gemini-buddy-mcp/buddy_server.mjs
@@ -37,6 +37,7 @@ function runGemini(text) {
child.stdout.on("data", (d) => { stdout += d; });
child.stderr.on("data", (d) => { stderr += d; });
child.on("error", reject);
+ child.stdin.on("error", reject); // fail the request instead of crashing on EPIPE
child.on("close", (exitCode) => {
if (exitCode === 0) resolve(stdout.trim());
else reject(new Error(stderr.trim() || `gemini exited with code ${exitCode}`));