Skip to content

Resolve stdin Promise on end event to support shell redirection - #5

Open
brlin-tw wants to merge 1 commit into
ricsam:mainfrom
brlin-tw:fix-shell-redirection-read
Open

brlin-tw wants to merge 1 commit into
ricsam:mainfrom
brlin-tw:fix-shell-redirection-read

Conversation

@brlin-tw

Copy link
Copy Markdown

When redirecting standard input from a file (e.g. < settings.json), Node's process.stdin stream emits an end event upon reaching EOF, but does not emit a close event.

Because stdin() previously only listened for close, reading from file redirection left the Promise permanently unresolved. Node's event loop would drain after end, causing the process to exit silently with status code 0 without producing output.

Listen on the end event instead of close so that both piped input and shell file redirection resolve properly.

Assisted-by: Antigravity:gemini-3.6-flash
Tested-by: Buo-ren Lin buo.ren.lin@gmail.com

When redirecting standard input from a file (e.g. < settings.json), Node's process.stdin stream emits an end event upon reaching EOF, but does not emit a close event.

Because stdin() previously only listened for close, reading from file redirection left the Promise permanently unresolved. Node's event loop would drain after end, causing the process to exit silently with status code 0 without producing output.

Listen on the end event instead of close so that both piped input and shell file redirection resolve properly.

Assisted-by: Antigravity:gemini-3.6-flash
Tested-by: Buo-ren Lin <buo.ren.lin@gmail.com>
Signed-off-by: 林博仁(Buo-ren Lin) <buo.ren.lin@gmail.com>
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.

1 participant