watch mode triggers unsolicided messages to Workers
Personne n'a encore pris cette issue.
- Langage dominant
- JavaScript
- Étoiles
- 122k
- Forks
- 37.3k
- Merge moyen
- 4 j 2 h
- PR mergées (30 j)
- 283
Description
Version
24.19.0, 26.6.0
Platform
Linux 05338a186e89 6.18.33.1-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Fri Jun 5 01:12:21 UTC 2026 x86_64 Linux
Subsystem
worker
What steps will reproduce the bug?
given the following two files:
// main.mjs
import { Worker } from 'worker_threads'
const worker = new Worker('./worker.js')
worker.on('message', console.log)
// worker.js (can be empty)
it can be reproduced using node --watch main.mjs.
The behavior is identical when using an equivalent main.cjs instead.
How often does it reproduce? Is there a required condition?
reproduces consistently
What is the expected behavior? Why is that the expected behavior?
applications should not receive unexpected (and undocumented) messages by the engine.
What do you see instead?
Unsolicided "watch:require" messages are sent.
Additional information
This issue effects v24 and v26, as can be seen in the following log (tested with node.js v22.23.1, v23.11.1, v24.19.0, v25.9.0, v26.6.0; note that I aborted each run with ctrl+c)
$ docker run --rm -v .:/app -w /app node:22-alpine node --watch main.mjs
Completed running 'main.mjs'. Waiting for file changes before restarting...
$ docker run --rm -v .:/app -w /app node:23-alpine node --watch main.mjs
Completed running 'main.mjs'
$ docker run --rm -v .:/app -w /app node:24-alpine node --watch main.mjs
{ 'watch:require': [ '/app/worker.js' ] }
Completed running 'main.mjs'. Waiting for file changes before restarting...
$ docker run --rm -v .:/app -w /app node:25-alpine node --watch main.mjs
Completed running 'main.mjs'. Waiting for file changes before restarting...
$ docker run --rm -v .:/app -w /app node:26-alpine node --watch main.mjs
{ 'watch:require': [ '/app/worker.js' ] }
Completed running 'main.mjs'. Waiting for file changes before restarting...
Though robust message handling code should always validate and check received messages, such unexpected messages can lead to unexpected behavior, e.g. crashes. This unexpected node.js behavior leads to the following issue downstream with an XML schema validating library: https://github.com/noppa/xmllint-wasm/issues/37
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.
Piste de recherche
Commencez par exécuter la reproduction signalée avec main.mjs, worker.js et node --watch, puis suivez le traitement du worker et du mode watch qui émet le message "watch:require". Le travail est terminé lorsque le worker ne reçoit aucun message non sollicité dans ce cas et qu’une couverture de régression existe pour le comportement systématiquement reproductible.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript, node.js
- Domaine
- backend
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- Calme
- Clarté
- Plutôt claire
- Accessibilité débutants
- 55/100