nodejs / nodejs/node

stat.isFIFO() is wrongly marked as always false on Windows, even when piping into a node process

未关闭
#57,603 10 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

fs windows
主要语言
JavaScript
星标
122k
派生
37.3k
平均合并
4 天 2 小时
30 天内合并 PR
283

描述

Version

v22.14.0

Platform
Microsoft Windows NT 10.0.26120.0 x64 [although this is on ARM64]
Subsystem

No response

What steps will reproduce the bug?

Running echo '{}' | node -e 'console.log(require("fs").fstatSync(0).mode)' in PowerShell (as cmd doesn't seem to support pipes via the usual syntax) returns 4096, and checking fs.constants, S_IFIFO is set to 4096.

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

Seems to be all the time on Windows when you try to pipe something in, which is due to a (I assume legacy?) check here: https://github.com/nodejs/node/blob/c3b6f949748b49ef25b0239bd4582d29976fdbad/lib/internal/fs/utils.js#L538-L541

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

On Windows, stat.isFIFO() should correctly handle pipes and stat.isFIFO() should correctly return true when piped in

What do you see instead?

stat.isFIFO() always returns false on Windows, even if the mode has the flag set

Additional information

I would love to submit a PR to fix this, but I am not sure if those checks are there for a reason or for legacy purposes (it seems that at least the S_ISFIFO is now exposed but it wasn't before [?]), and if it can be edited safely.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

在 Windows 上运行报告中的 PowerShell 管道,然后检查 lib/internal/fs/utils.js 第 538-541 行附近的平台特定检查。确定 FIFO 检测为何排除 Windows 管道,并验证在通过管道传入 stdin 的情况下 stat.isFIFO() 返回 true,同时不更改其他文件类型检查。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, node.js
领域
operating-systems
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
55/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。