Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
`for await (const c of process.stdin)` does not accept EOF in Windows | GoodFirstPicks

`for await (const c of process.stdin)` does not accept EOF in Windows

nodejs/node 0 comments 1mo ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeNode.jsJavaScript

Why this is a good first issue

Platform-specific EOF handling in Windows requires careful implementation.

AI Summary

The issue involves inconsistent EOF handling in Windows when using `for await` with `process.stdin`, where Ctrl+Z or Ctrl+D does not terminate the input loop as expected. The fix likely requires modifying stream handling logic to properly detect EOF signals on Windows, but platform-specific behavior adds complexity.

Issue Description

Version

v24.13.0

Platform

Microsoft Windows NT 10.0.26200.0 x64

Subsystem

No response

What steps will reproduce the bug?

  1. Run node -e "for await (const c of process.stdin) console.log(c)"
  2. [f] [o] [o] [Enter]
  3. [Ctrl] + [Z] or [Ctrl] + [D] (= EOF)
  4. [Enter]

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

In Ubuntu and Alma Node successfully stop reading by Ctrl + D:

$ node -e "for await (const c of process.stdin) console.log(c)"
foo
<Buffer 66 6f 6f 0a>

What do you see instead?

Node will never stop reading in spite of [Ctrl] + [Z] or [Ctrl] + [D]:

PS> node -e "for await (const c of process.stdin) console.log(c)"
foo
<Buffer 66 6f 6f 0d 0a>
^Z
<Buffer 1a 0d 0a>
^D
<Buffer 04 0d 0a>

I had to end up with killing the process by Ctrl + C.

Additional information

I usually use Proto to manage Node versions, but it was able to be reproduced in the portable version in the official zipball:

PS> .\Downloads\node-v24.13.0-win-x64\node -e "for await (const c of process.stdin) console.log(c)"
foo
<Buffer 66 6f 6f 0d 0a>
^Z
<Buffer 1a 0d 0a>
^D
<Buffer 04 0d 0a>

PS> echo $?
False

(ended up with Ctrl + C)

Workaround: insert if ((c[0] === 4 || c[0] === 0x1a) && c.length === 1 + EOL.length && c.toString("latin1", c.length - EOL.length) === EOL) break; (import { EOL } from "node:os")

If this bug did not exist, you would be able to retrieve the entire multiline text from stdin by (await Array.fromAsync(process.stdin)).join("") in all platforms.

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!

Risk Flags

  • platform-specific behavior
  • stream handling
Loading labels...

Details

Points10 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno