nx
nx copied to clipboard
Nx watch goes into indefinite loop
Current Behavior
Hi! I think I just managed to reproduce a situation when nx watch goes into an indefinite loop constantly running same task again and again. It runs build command which is supposed to be cached ( and it is ) but DaemonSocketMessenger keeps receiving the information that file is changed and runs same command again.
Expected Behavior
It's ok if watch command listens for all files ( ideally I would prefer that watch can also accept somehow only certain files to watch, not for everything ) but even though it should not run the command again if file was processed ( target inputs are not changed and target result is cached )
GitHub Repo
https://github.com/ThePlenkov/nx-plantuml
Steps to Reproduce
Preferably open repo in codespaces or make sure you have docker installed ( for command execution )
- npm run dev
- Make any change, like for example add a new line to readme
Nx Report
Node : 20.12.1
OS : linux-x64
npm : 10.5.0
nx : 18.3.1
@nrwl/tao : 18.3.1
Failure Logs
No response
Package Manager Version
No response
Operating System
- [ ] macOS
- [X] Linux
- [ ] Windows
- [ ] Other (Please specify)
Additional Information
No response
I tried to disable daemon - it stays same
tried to use nx:run-commands executor instead of npm script - same result..
Did you try to add
"nx": { "includedScripts": [] }
to package json
On vacation now - will check when come. But from another side I don't want to ignore scripts, I think what happens - is that watch doesn't analyze inputs and outputs properly running task even if it's cached
Hey! Is this still happening to you on the latest version of nx @ThePlenkov?
I fixed an issue a while back where the daemon would sometimes pick up changes inside the .nx
folder or something like that and it was causing loops in Nx Console as well.
Could you please confirm that it still happens for you? In that case I will try and track it down.
@MaxKless I tried but I cannot run 'nx watch` anymore. I have this
npm run dev
> [email protected] dev
> nx watch --all -- npx nx build \$NX_PROJECT_NAME
NX Daemon is not running. The watch command is not supported without the Nx Daemon.
and even if I do this - it doesn't help:
npx nx daemon --start
NX Daemon Server - Started in a background process...
Logs from the Daemon process (ID: 6672) can be found here: /workspaces/nx-plantuml/.nx/workspace-data/d/daemon.log
here is a similar issue: https://github.com/lerna/lerna/issues/4054
I also see that daemon is actually running:
npx nx daemon
Nx Daemon is currently running:
- Logs: /workspaces/nx-plantuml/.nx/workspace-data/d/daemon.log
- Process ID: 6672
@ThePlenkov ➜ /workspaces/nx-plantuml (main) $ npm run dev
> [email protected] dev
> nx watch --all -- npx nx build \$NX_PROJECT_NAME
NX Daemon is not running. The watch command is not supported without the Nx Daemon.
and here is the log:
[NX Daemon Server] - 2024-08-01T10:14:32.596Z - Started listening on: /tmp/3cb767b5e4c3571b057f/d.sock
[NX Daemon Server] - 2024-08-01T10:14:32.598Z - [WATCHER]: Subscribed to changes within: /workspaces/nx-plantuml (native)
[NX Daemon Server] - 2024-08-01T10:14:32.603Z - Established a connection. Number of open connections: 1
[NX Daemon Server] - 2024-08-01T10:14:32.605Z - Closed a connection. Number of open connections: 0
[NX Daemon Server] - 2024-08-01T10:21:02.298Z - Established a connection. Number of open connections: 1
[NX Daemon Server] - 2024-08-01T10:21:02.300Z - Closed a connection. Number of open connections: 0
you can reproduce yourself - just by running npm run dev
in a codespace for this project https://github.com/ThePlenkov/nx-plantuml
This issue has been automatically marked as stale because no results of retrying on the latest version of Nx was provided within 7 days. It will be closed in 21 days if no results are provided. If the issue is still present, please reply to keep it active. If the issue was not present, please close this issue. Thanks for being a part of the Nx community! 🙏