nodejs / nodejs/node

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

Aperta
#57,603 10 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

fs windows
Lingua principale
JavaScript
Stelle
122k
Fork
37.3k
Merge medio
4g 2h
PR unite (30g)
283

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Esegui la pipeline PowerShell segnalata su Windows, quindi esamina i controlli specifici della piattaforma in lib/internal/fs/utils.js intorno alle righe 538-541. Determina perché il rilevamento delle FIFO esclude le pipe di Windows e verifica che stat.isFIFO() restituisca true nel caso dell'input standard tramite pipe, senza modificare gli altri controlli dei tipi di file.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, node.js
Ambito
operating-systems
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.