process.exit() terminates before Node drains asynchronous stdout or stderr. A command that writes and then forces an exit can truncate under a pipe or output capture.
The shipped pty completions command demonstrated the failure. A conformance suite found it before a user report: the command returned success with truncated output, and no error identified the loss.
The production source has 152 remaining process.exit() sites. Of these, 146 can follow output written by this process:
- 125 stderr exits follow error text.
- Three stdout exits follow usage text.
- Two exits follow interactive prompts.
- Eight local or remote attach and peek callbacks can follow streamed terminal output.
- One client fallback can follow attach output.
- One stdio remote-control exit can follow protocol output.
- Four TUI exits follow terminal restoration writes.
- Two event signal handlers can follow event output.
The 125 stderr sites are important because redirection is common during diagnosis. The command can preserve its nonzero status while losing the message that explains it.
The known fix shape is small: set process.exitCode and return, which lets Node finish pending writes. The groups need separate scope decisions because usage, errors, streams, protocols, and terminal restoration have different risks.
The deterministic reproduction in PR #178 delays every stdout write. The old forced-exit path produces empty output; the natural-exit path produces the complete checked-in artifact. Any broader change needs an equivalent failing control before it changes behavior.
process.exit()terminates before Node drains asynchronous stdout or stderr. A command that writes and then forces an exit can truncate under a pipe or output capture.The shipped
pty completionscommand demonstrated the failure. A conformance suite found it before a user report: the command returned success with truncated output, and no error identified the loss.The production source has 152 remaining
process.exit()sites. Of these, 146 can follow output written by this process:The 125 stderr sites are important because redirection is common during diagnosis. The command can preserve its nonzero status while losing the message that explains it.
The known fix shape is small: set
process.exitCodeand return, which lets Node finish pending writes. The groups need separate scope decisions because usage, errors, streams, protocols, and terminal restoration have different risks.The deterministic reproduction in PR #178 delays every stdout write. The old forced-exit path produces empty output; the natural-exit path produces the complete checked-in artifact. Any broader change needs an equivalent failing control before it changes behavior.