Let completion output drain before exit - #178
Merged
Merged
Conversation
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.
pty completions fishandpty completions zshcould exit before a pipe drained. Both commands returned success with truncated output.This change sets the exit code and returns from the CLI entry point. Node then finishes pending stdout writes before it exits.
The direct failure reproduced on Linux with Node 24.18.0. It did not reproduce on macOS with Node 22.21.1 or Node 24.0.2, so the unmodified race is runtime and platform dependent.
The regression delays each stdout write. Under both Node 22.21.1 and Node 24.0.2, it received empty output before the fix and each complete artifact after the fix. This control does not depend on pipe size or scheduling luck.
Remaining forced-exit audit
The production source has 152 other
process.exit()calls. Of these, 146 can follow output written by this process:run,attach,exec,peek,send,events,list,remote-serve,restart,kill,recover,gc,tag,rm,metadata,evidence,rename,tag-multi,emit,up,down, andstats, plus client and daemon failures.tag-multi --help, or invalidemitusage.The remaining six sites do not leave process-owned output pending. Four follow synchronous child commands with inherited stdio, one finishes a silent send, and one finishes a normal daemon shutdown.
These paths are reachable through ordinary commands, validation failures, session lifecycle, remote access, and signals. A terminal user usually sees short errors immediately. Pipes and log collectors can lose them while preserving only the exit status. The stdout, streamed-output, protocol, and terminal-restoration paths are directly visible and can truncate user data.
This pull request changes only the completion exit. The other sites need separate review.
Verification
Incomplete terminfo entry; this change does not affect them.