--watch-path restarts on unrelated directory touch when --env-file is set
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 122k
- Fork
- 37.3k
- Merge medio
- 4g 2h
- PR unite (30g)
- 283
Descrizione
Version
- Node.js: v24.13.0
- OS: macOS
Reproduction
Setup:
mkdir -p /tmp/node-watch-envfile-repro/watched /tmp/node-watch-envfile-repro/unrelated
cd /tmp/node-watch-envfile-repro
echo "FOO=bar" > .env
echo "console.log('START', JSON.stringify({ pid: process.pid, ts: Date.now(), foo: process.env.FOO ?? null }));" > watched/server.js
echo "setInterval(() => {}, 1000);" >> watched/server.js
Run with --env-file and touch an unrelated path:
cd /tmp/node-watch-envfile-repro
node --watch-path=watched --env-file=.env watched/server.js > out-env.log 2>&1 &
PID=$!
sleep 2
touch unrelated
sleep 2
kill $PID
cat out-env.log
Observed output:
START {"pid":58939,"ts":1771621917212,"foo":"bar"}
Restarting 'watched/server.js'
START {"pid":58948,"ts":1771621919442,"foo":"bar"}
Now run without --env-file:
cd /tmp/node-watch-envfile-repro
node --watch-path=watched watched/server.js > out-no-env.log 2>&1 &
PID=$!
sleep 2
touch unrelated
sleep 2
kill $PID
cat out-no-env.log
Observed output:
START {"pid":59279,"ts":1771621950778,"foo":null}
Expected behavior
When --watch-path=watched is set, touching unrelated should not trigger a restart, regardless of whether --env-file is used.
Actual behavior
With --env-file=.env, touching unrelated triggers a restart.
Without --env-file, touching unrelated does not restart.
Notes
This was first noticed in a larger workspace where:
node --watch-path=apps/server/dist-dev --env-file=.env apps/server/dist-dev/server.js
restarts when running:
touch apps/client/dist/
The reduced test case above reproduces the same behavior.
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.
Direzione di ricerca
Inizia eseguendo la riproduzione macOS fornita con e senza --env-file, concentrandoti sulla gestione di watch-path da parte di Node.js e sull’interazione con l’entry point --env-file. Traccia il punto in cui vengono selezionati i percorsi del filesystem da monitorare e aggiungi o aggiorna un test di regressione in modo che la modifica di qualcosa di non correlato non riavvii il processo; esegui nuovamente la riproduzione e i test watch pertinenti per confermare il comportamento.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, node.js
- Ambito
- cli, tooling
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 64/100