Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--watch-path also watches --env file directory tree in >=22.7 #55913

Open
gorankarlic opened this issue Nov 19, 2024 · 6 comments
Open

--watch-path also watches --env file directory tree in >=22.7 #55913

gorankarlic opened this issue Nov 19, 2024 · 6 comments

Comments

@gorankarlic
Copy link

gorankarlic commented Nov 19, 2024

Version

22.7.0

Platform

Darwin Users-MacBook-Air-2.local 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:37:13 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T8112 arm64

Subsystem

No response

What steps will reproduce the bug?

When running node --watch-path lib test.js with 22.6.0 it behaves as expected (restarts only when a file changes in the lib directory).

When running node --watch-path lib test.js with 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

@targos
Copy link
Member

targos commented Nov 19, 2024

I'm not able to reproduce.

@gorankarlic
Copy link
Author

gorankarlic commented Nov 20, 2024

I 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:

  1. --env argument must be present
  2. --watch-path argument must be present

--watch-preserve-output is used here only for easier observation but is not required to reproduce the issue

node --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 casedev.env) is located. That means that executing touch sub/test.txt triggers a restart.

Please find attached a complete example 55913.zip that can be used with the above description to reliably reproduce the issue.

@pmarchini
Copy link
Member

Hey @gorankarlic, could you please provide the repro as a public repository? 😊

@gorankarlic
Copy link
Author

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.

@pmarchini
Copy link
Member

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.

Thanks @gorankarlic 😊

@gorankarlic gorankarlic changed the title --watch-path broken starting with version 22.7 --watch-path also watches --env file directory tree in >=22.7 Nov 21, 2024
@gorankarlic
Copy link
Author

It seems that the pull request #54109 that was merged into 22.7 introduced this issue, i.e. instead of watching just the env file it watches the directory tree where the env file is located. @marekpiechut any ideas how it could be fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants