Skip to content

Commit efffe69

Browse files
cameroncookecodex
andcommitted
fix(benchmarks): Handle Claude command stdin pipe errors
Handle stdin stream errors from benchmark child processes so an early child exit does not crash the harness with an unhandled EPIPE. Co-Authored-By: Codex <noreply@openai.com>
1 parent cd53c71 commit efffe69

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

src/benchmarks/claude-ui/harness.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,17 @@ function runCommand(opts: {
246246
hardKillTimer = undefined;
247247
};
248248

249+
const rejectCommand = (error: Error): void => {
250+
if (settled) return;
251+
settled = true;
252+
clearTerminalResultTimer();
253+
clearTimeoutTimer();
254+
clearHardKillTimer();
255+
stdout.destroy();
256+
stderr.destroy();
257+
reject(error);
258+
};
259+
249260
const killChild = (signal: NodeJS.Signals): void => {
250261
if (child.exitCode !== null || child.killed || child.pid === undefined) return;
251262
try {
@@ -317,14 +328,11 @@ function runCommand(opts: {
317328
stderr.write(chunk);
318329
});
319330
child.on('error', (error) => {
320-
if (settled) return;
321-
settled = true;
322-
clearTerminalResultTimer();
323-
clearTimeoutTimer();
324-
clearHardKillTimer();
325-
stdout.destroy();
326-
stderr.destroy();
327-
reject(error);
331+
rejectCommand(error);
332+
});
333+
child.stdin.on('error', (error: NodeJS.ErrnoException) => {
334+
if (error.code === 'EPIPE') return;
335+
rejectCommand(error);
328336
});
329337
child.on('close', (exitCode) => {
330338
if (settled) return;

0 commit comments

Comments
 (0)