--watch-path restarts on unrelated directory touch when --env-file is set
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 122k
- フォーク
- 37.3k
- 平均マージ
- 4日 2時間
- マージ済み PR(30日)
- 283
説明
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.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供されている macOS の再現手順を --env-file ありとなしで実行し、Node.js の watch-path の処理と --env-file エントリポイントとの相互作用に注目します。監視対象のファイルシステムパスがどこで選択されているかを追跡し、無関係なものに触れてもプロセスが再起動しないことを確認する回帰テストを追加または更新します。その後、再現手順と関連する watch テストを再実行して、動作を確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, node.js
- 領域
- cli, tooling
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 64/100