From b6ccf12551bf43992b89c8b2c78d1352e89787eb Mon Sep 17 00:00:00 2001 From: Keith Ballinger Date: Tue, 24 Jun 2025 17:39:01 -0700 Subject: [PATCH] [June 25] handle early output pipe closer (#1402) --- packages/cli/src/nonInteractiveCli.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/cli/src/nonInteractiveCli.ts b/packages/cli/src/nonInteractiveCli.ts index 28db73f1..0855fc6d 100644 --- a/packages/cli/src/nonInteractiveCli.ts +++ b/packages/cli/src/nonInteractiveCli.ts @@ -47,6 +47,14 @@ export async function runNonInteractive( config: Config, input: string, ): Promise { + // Handle EPIPE errors when the output is piped to a command that closes early. + process.stdout.on('error', (err: NodeJS.ErrnoException) => { + if (err.code === 'EPIPE') { + // Exit gracefully if the pipe is closed. + process.exit(0); + } + }); + const geminiClient = config.getGeminiClient(); const toolRegistry: ToolRegistry = await config.getToolRegistry();