-
-
Notifications
You must be signed in to change notification settings - Fork 34.9k
Open
Description
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.jsRun 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.logObserved 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.logObserved 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.jsrestarts when running:
touch apps/client/dist/The reduced test case above reproduces the same behavior.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels