--watch prints messages to stdout, but should print to stderr
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 76/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Tranquilla
- Stack tecnologico
- javascript
- Ambito
- cli
Direzione di ricerca
Inizia da lib/internal/main/watch_mode.js, in particolare dall'uso di stdout vicino alla riga collegata, ed esegui la riproduzione indicata node --watch index.mjs con stderr reindirizzato. Il lavoro è completato quando i messaggi della modalità watch, come "Restarting 'index.mjs'", vengono inviati a stderr, in modo che 2>/dev/null li sopprima e non interferiscano con la stdout del programma.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Version
v22.12.0
Platform
macOS (but reading the source code of Node.js the issue should be present on any platform)
Subsystem
node/lib/internal/main/watch_mode.js
What steps will reproduce the bug?
echo 'process.stdin.resume()' >index.mjs
node --watch index.mjs 2>/dev/null
In another terminal:
touch index.mjs
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior? Why is that the expected behavior?
Nothing is printed, since I redirect stderr to /dev/null.
What do you see instead?
Restarting 'index.mjs' is printed (to stdout).
Additional information
How to use stdout and stderr is purely conventional, but the GNU C library says:
stdout: The standard output stream, which is used for normal output from the program.
stderr: The standard error stream, which is used for error messages and diagnostics issued by the program.
I’m making a program that reads input from stdin and writes to stdout. It is a long-lived program: Another program writes to stdin over time, and consumes output from stdout. I use --watch so I can iterate on the sub-program more easily. Unfortunately, --watch writes messages to stdout, causing the consuming program to receive output it does not expect.
I would argue that my program creates the “normal output” while the --watch messages are “diagnostics”.
Here’s one of the places where stdout is used instead of stderr: https://github.com/nodejs/node/blob/9400eae52ee10f25d63c06c52479c033e3149580/lib/internal/main/watch_mode.js#L139
Is there a reason for this? Should it be changed to stderr?
- Lingua principale
- JavaScript
- Stelle
- 122k
- Fork
- 37.4k
- Merge medio
- 4g 3h
- PR unite (30g)
- 273
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nodejs/node
-
doc
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
build
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
feature request
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
Daemon passes --experimental-wasm-jspi unconditionally on Node >= 24; Node 26 rejects the flag Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Automattic/studio#4908 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
sugarlabs/musicblocks#8847 ·