nodejs / nodejs/node

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

Đang mở
#57,603 10 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

fs windows
Ngôn ngữ chính
JavaScript
Star
122k
Fork
37.4k
Merge trung bình
4 ngày 3 giờ
Pull request đã merge (30 ngày)
272

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Chạy pipeline PowerShell được báo cáo trên Windows, sau đó kiểm tra các kiểm tra dành riêng cho nền tảng trong lib/internal/fs/utils.js quanh các dòng 538-541. Xác định lý do việc phát hiện FIFO loại trừ các pipe của Windows và xác minh rằng stat.isFIFO() trả về true trong trường hợp stdin được pipe, mà không thay đổi các kiểm tra loại tệp khác.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, node.js
Lĩnh vực
operating-systems
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
55/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.