Skip to content

fix: ignore EPIPE on stdin when the process exits early - #193

Merged
43081j merged 2 commits into
tinylibs:mainfrom
ofri-peretz:fix/ignore-stdin-epipe
Nov 24, 2026
Merged

43081j merged 2 commits into
tinylibs:mainfrom
ofri-peretz:fix/ignore-stdin-epipe

Conversation

@ofri-peretz

Copy link
Copy Markdown
Contributor

If the child exits before reading all of a string stdin that is bigger than the pipe buffer, the write to its stdin fails with EPIPE. Nothing listens for error on handle.stdin, so the host process dies with an uncaught write EPIPE and the promise never settles.

await x('node', ['-e', 'process.exit(0)'], {stdin: 'x'.repeat(2_000_000)});

That crashed 3 of 3 runs on 1b31140 (Node 24). With this change it resolves with exitCode: 0.

I added an error listener on the child's stdin. EPIPE is ignored, since the child chose not to read and its exit code already says how it went (execa does the same for stdin). Any other stdin error goes through _thrownError.

The new test writes 4 MB to a child that exits at once. Without the fix, vitest reports an unhandled EPIPE; with it the test passes. I ran npm run build, format:check, lint and test:unit on Node 24 / macOS; the Windows and Node 20 jobs haven't run.

@43081j
43081j merged commit 229860b into tinylibs:main Nov 24, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants