Repository navigation
fix(cli): exit when the command dies from SIGPIPE - #1078
Merged
motdotla merged 1 commit intoOct 29, 2026
Merged
Conversation
Owner
|
nice catch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the command started by
dotenv runis killed by SIGPIPE, the CLI never exits. Native tools get SIGPIPE when the reader of a pipe stops early, for exampledotenv run -- cat app.log | headordotenv run -- grep ERROR app.log | headon a large file. The output is printed, then the pipeline hangs until Ctrl-C or a CI timeout. The same command without dotenv exits with 141.The exit handler re-raises the child's signal on itself and keeps the event loop alive with a
setIntervaluntil that signal arrives. Node ignores SIGPIPE, so it never arrives and the process stays alive forever. This replaces the interval with a 1ssetTimeoutthat exits with the shell's128 + signal numberstatus. Signals Node does not ignore still terminate the process by signal as before. SIGXFSZ had the same hang and now exits 153.Ran:
npm teston Windows: 1412 pass, 1 skip (POSIX signal tests skip on win32)tests/test-cli-signals.js: fails on master with ETIMEDOUT, passes with the fixChecked:
cat/grepon a 1M-line file piped tohead -n 1: PIPESTATUS124 0(timeout) on master,141 0with the fixsh -c 'kill -TERM $$'still exits 143,sh -c 'kill -KILL $$'137,sh -c 'exit 7'7