Repository navigation
--watch-path also watches --env file directory tree in >=22.7 #55913
Description
Activity
I'm not able to reproduce.
Reacted by gorankarlicI have discovered that the issue is a bit more convoluted and indeed can not be reproduced as stated above.
In order to reproduce the issue two conditions must be met:
--envargument must be present--watch-pathargument must be present
--watch-preserve-outputis used here only for easier observation but is not required to reproduce the issuenode --env-file sub/dev.env --watch-path /usr/local/bin --watch-preserve-output index.js
In this case Node 22.7 and above erroneously starts watching the directory tree where the environment file (in this case
dev.env) is located. That means that executingtouch sub/test.txttriggers a restart.Please find attached a complete example 55913.zip that can be used with the above description to reliably reproduce the issue.
Reacted by Alejandro SilvaHey @gorankarlic, could you please provide the repro as a public repository? 😊
Hey @gorankarlic, could you please provide the repro as a public repository? 😊
Please find the public repository with the reproducible at https://github.com/gorankarlic/55913.
Reacted by Pietro MarchiniHey @gorankarlic, could you please provide the repro as a public repository? 😊
Please find the public repository with the reproducible at https://github.com/gorankarlic/55913.
Thanks @gorankarlic 😊
- changed the title
[-]`--watch-path` broken starting with version 22.7[/-][+]`--watch-path` also watches `--env` file directory tree in >=22.7[/+]on Nov 21, 2024 It seems that the pull request #54109 that was merged into 22.7 introduced this issue, i.e. instead of watching just the
envfile it watches the directory tree where theenvfile is located. @marekpiechut any ideas how it could be fixed?Reacted by Piotr and oli- added a commit that references this issue
on Jan 16, 2025 github-actions commented
on Apr 26, 2026 on Apr 26, 2026 – with GitHub ActionsContributorMore actionsThis issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.- addedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on Apr 26, 2026 github-actions commented
on May 26, 2026 on May 26, 2026 – with GitHub ActionsContributorMore actionsThis issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 240 days).
If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.
Version
22.7.0
Platform
Subsystem
No response
What steps will reproduce the bug?
When running
node --watch-path lib test.jswith 22.6.0 it behaves as expected (restarts only when a file changes in thelibdirectory).When running
node --watch-path lib test.jswith 22.7.0 it keeps restarting indefinitely.How often does it reproduce? Is there a required condition?
Always reproducible.
What is the expected behavior? Why is that the expected behavior?
Should only restart when a file changes in the watched directory.
What do you see instead?
Restarting indefinitely in a loop.
Additional information
No response