Skip to content

End the run as usual when the reader of a pipe stops early to close #839 - #840

Merged
mathiasrw merged 29 commits into
mainfrom
fix/839
Oct 23, 2026
Merged

mathiasrw merged 29 commits into
mainfrom
fix/839

Conversation

@mathiasrw

@mathiasrw mathiasrw commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Closes #839

Stacked on #838.

Change

When the reader of a pipe stops early, like head, nobody reads the rest, and that is fine. Before, the run crashed with EPIPE and a stack trace, and exit code 1:

> rexreplace foo bar big.txt -o | head -1
1 bar
EPIPE: broken pipe, write
…

Now the run ends as usual, with no error, on Bun and on Node:

  • Bun throws when a closed pipe is written to, and Node gives an error event, so both are caught. All other errors are thrown as before.
  • After that, nothing more is written to that stream.
  • The status report goes through the same write, so -d | head -1 is fine too.

Tests

test/fix/839.test.js is new. It pipes 200,000 lines into head -1, also with the status report, and fails without the fix. yarn test-ci passes.

Also closes #852

Follow-up

The detail of an error, like the file, is now on its own line under the message, for every error:

 ❌ File not found
    a.md

@mathiasrw
mathiasrw added this pull request to stack #841 October 23, 2026 13:56
@mathiasrw
mathiasrw removed this pull request from stack #841 October 23, 2026 15:57
@mathiasrw
mathiasrw added this pull request to stack #849 October 23, 2026 16:12
@mathiasrw
mathiasrw removed this pull request from stack #849 October 23, 2026 16:12
@mathiasrw
mathiasrw added this pull request to stack #850 October 23, 2026 16:17
@mathiasrw
mathiasrw removed this pull request from stack #850 October 23, 2026 16:47
@mathiasrw
mathiasrw added this pull request to stack #853 October 23, 2026 16:51
Base automatically changed from fix/821 to main October 23, 2026 17:04
@mathiasrw
mathiasrw merged commit c24ad17 into main Oct 23, 2026
7 checks passed
@mathiasrw
mathiasrw deleted the fix/839 branch October 23, 2026 17:13
mathiasrw added a commit that referenced this pull request Oct 23, 2026
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.

Put the detail of an error on its own line Fix a crash with a stack trace when stdout is closed early, like with head

1 participant