-
-
Notifications
You must be signed in to change notification settings - Fork 34k
module: read from stdin when input is a pipe #60659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Update the CommonJS module loader to detect when the input filename is /dev/stdin and stdin is a pipe (FIFO). In such cases, read directly from file descriptor 0 instead of attempting to open the /proc/<pid>/fd/pipe:[...] path, which can result in ENOENT errors. This change ensures that running Node with piped input like: printf 'console.log(1)' | node /dev/stdin works reliably on Linux systems. Fixes: nodejs#54200
|
Review requested:
|
|
Why not use $ printf 'console.log(1)' | node -
1
$ printf 'console.log(1)' | node
1 |
Your snippet works correctly on Linux, but the issue specifically affects the case where On macOS, The fix ensures consistent behavior across platforms for this pattern. |
|
This sort of thing has been reported before (#60342) but I wouldn't say that a hardcoded check for one specific path lends "consistency", and it's probably the one with the least motivation to address, given that – as mentioned – there's no need to provide a path to stdin to the CLI at all. As far as the loader handling quirky symlinks to anonymous pipes goes, you can pass |
|
@Renegade334 Thanks for providing more context. |
Update the CommonJS module loader to detect when the input filename is /dev/stdin and stdin is a pipe. In such cases, read directly from file descriptor 0 instead of attempting to open the /proc//fd/pipe:[...] path, which can result in ENOENT errors.
This change ensures that running Node with piped input like:
printf 'console.log(1)' | node /dev/stdin
works reliably on Linux systems.
Fixes: #54200