Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions documentation/PULL_REQUESTS/2026-05-01-fix-help-path-flush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Problem

After PR #7 eliminated one data-loss bug (truncated output when piping large command output), a review noted that the same bug class lingered in our help / version output paths. Someone running `fullcontext --help | head` could theoretically see a truncated help message — the same mechanism as before: our code prints output and then exits synchronously, which on Node doesn't wait for buffered pipe writes to reach the operating system.

## Solution

Apply the identical fix to the remaining exits after writes. Tell Node the exit code we want and let the runtime exit naturally once all output has flushed. No new bug, no new test, just the same correct pattern applied consistently.

## Impact

- No more silent truncation bugs anywhere in the CLI.
- No behavior change for non-piped usage — exit codes and help output are identical.
- Small follow-up to PR #7; single-file change.

# Credits

- Nabs (Architect)
- JENA (Lead Developer)
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,12 @@ function main(): void {
// Display usage if no arguments provided or help requested
if (args.length === 0 || args[0] === '--help' || args[0] === '-h') {
console.log(USAGE);
process.exit(0);
// Set exitCode + return rather than process.exit(): when stdout is a
// pipe (e.g. `fullcontext --help | head`), synchronous process.exit
// can drop buffered writes before libuv has flushed them to the OS.
// See the matching pattern in executeCommand's 'close' handler.
process.exitCode = 0;
return;
}

// Join all arguments into a single command string for shell execution
Expand Down
Loading