Skip to content

Commit af0f2ed

Browse files
committed
fix(hooks): swallow async EPIPE on hook-stdin write
Hooks whose command exits before reading stdin emit EPIPE on the async 'error' event — outside the sync try/catch — which node escalates to an unhandled stream error. Vitest counts that as a suite failure in CI even when every assertion passes. Adding a no-op error listener absorbs it.
1 parent 9d7cac5 commit af0f2ed

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codebase-cli",
3-
"version": "2.0.0-pre.63",
3+
"version": "2.0.0-pre.64",
44
"description": "Codebase CLI — a TypeScript coding agent on the pi-mono runtime. OAuth-aware, any LLM provider, single install.",
55
"keywords": [
66
"ai",

src/hooks/runner.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ export function runHook(config: HookConfig, context: HookEventContext, signal?:
6060
};
6161
signal?.addEventListener("abort", onAbort);
6262

63+
// EPIPE is async (emitted on stdin's 'error' event) when the child
64+
// exits before consuming our payload — a sync try/catch misses it
65+
// and node treats unhandled-stream-error as a process exception.
66+
// Swallow the stream error explicitly; close-on-fast-exit is fine.
67+
child.stdin?.on("error", () => {});
6368
try {
6469
child.stdin?.write(JSON.stringify(context));
6570
child.stdin?.end();

0 commit comments

Comments
 (0)