Skip to content

Exit quietly when stdout is closed early - #1564

Merged
ai merged 2 commits into
postcss:mainfrom
KhaledSaeed18:fix-closed-stdout
Nov 15, 2026
Merged

ai merged 2 commits into
postcss:mainfrom
KhaledSaeed18:fix-closed-stdout

Conversation

@KhaledSaeed18

@KhaledSaeed18 KhaledSaeed18 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

autoprefixer --version and --help crash with Error: write EPIPE, a stack trace and exit code 1 when the reader closes the pipe first (| head, grep -q, set -o pipefail in CI).

Node turns the closed pipe into an EPIPE error on process.stdout; with no listener it is uncaught. This adds a listener that exits quietly with 0 on EPIPE and rethrows anything else.

I first added a test that spawns the bin with its stdout destroyed; it was removed at review. pnpm test passes (lint, coverage, size limit).

Comment thread test/bin.test.js Outdated
@@ -0,0 +1,30 @@
let { spawn } = require('child_process')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this test

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@ai
ai merged commit 9cde2bf into postcss:main Nov 15, 2026
9 checks passed
@ai

ai commented Nov 15, 2026

Copy link
Copy Markdown
Member

Thanks

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