nodejs / nodejs/node

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

オープン
#57,603 コメント 10 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

fs windows
主要言語
JavaScript
スター
122k
フォーク
37.3k
平均マージ
4日 2時間
マージ済み PR(30日)
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. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

報告された PowerShell パイプラインを Windows 上で実行し、その後 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 を短くまとめたダイジェスト。