--watch prints messages to stdout, but should print to stderr
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 76/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Calme
- Stack technique
- javascript
- Domaine
- cli
Piste de recherche
Commencez dans lib/internal/main/watch_mode.js, en particulier au niveau de l’utilisation de stdout près de la ligne liée, et exécutez la reproduction signalée node --watch index.mjs avec stderr redirigé. C’est terminé lorsque les messages du mode watch tels que "Restarting 'index.mjs'" sont envoyés vers stderr, afin qu’ils soient supprimés par 2>/dev/null et n’interfèrent pas avec la stdout du programme.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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?
- Langage dominant
- JavaScript
- Étoiles
- 122k
- Forks
- 37.4k
- Merge moyen
- 4 j 3 h
- PR mergées (30 j)
- 273
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de nodejs/node
-
doc
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
-
build
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
-
feature request
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Toutes les issues de nodejs/node
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
-
Daemon passes --experimental-wasm-jspi unconditionally on Node >= 24; Node 26 rejects the flag Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Automattic/studio#4908 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
sugarlabs/musicblocks#8847 ·