nx: Problem with NX Daemon after update from 15.9.2 to 16.0.3

Current Behavior

After the update to 16.0.3 builds (also tests) sometimes fail with the message Unable to connect to the daemon process. with an error fatal: no path specified (see Failure Logs)

Expected Behavior

The build and test commands should work as expected

GitHub Repo

No response

Steps to Reproduce

  1. Update from nx version15.9.2 to 16.0.3
  2. Run nx reset
  3. Run nx run-many --all --target=build --skip-nx-cache

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 18.13.0
   OS     : linux x64
   npm    : 8.19.3
   Hasher : Native

   nx                 : 16.0.3
   @nx/js             : 16.0.3
   @nx/jest           : 16.0.3
   @nx/linter         : 16.0.3
   @nx/workspace      : 16.0.3
   @nx/angular        : 16.0.3
   @nx/cypress        : 16.0.3
   @nx/devkit         : 16.0.3
   @nx/eslint-plugin  : 16.0.3
   @nx/nest           : 16.0.3
   @nx/node           : 16.0.3
   @nx/storybook      : 16.0.3
   @nrwl/tao          : 16.0.3
   @nx/webpack        : 16.0.3
   typescript         : 4.9.5
   ---------------------------------------
   Community plugins:
   @storybook/angular : 7.0.8

Failure Logs

➜  time node_modules/.bin/nx run-many --all --target=build --skip-nx-cache
 >  NX   Unable to connect to the daemon process.


   Messages from the log:
   [NX Daemon Server] - 2023-05-03T11:46:19.868Z - Established a connection. Number of open connections: 1
   [NX Daemon Server] - 2023-05-03T11:46:19.869Z - Established a connection. Number of open connections: 2
   [NX Daemon Server] - 2023-05-03T11:46:19.870Z - Closed a connection. Number of open connections: 1
   [NX Daemon Server] - 2023-05-03T11:46:19.872Z - [REQUEST]: Client Request for Project Graph Received
   fatal: no path specified
   [NX Daemon Server] - 2023-05-03T11:46:19.932Z - [REQUEST]: Updated file-hasher based on watched changes, recomputing project graph...
   [NX Daemon Server] - 2023-05-03T11:46:20.194Z - [REQUEST]: Responding to the client. project-graph
   [NX Daemon Server] - 2023-05-03T11:46:20.198Z - Time taken for 'total for creating and serializing project graph' 322.09956800192595ms
   [NX Daemon Server] - 2023-05-03T11:46:20.198Z - [WATCHER]: Subscribed to changes within: /home/user
   [NX Daemon Server] - 2023-05-03T11:46:20.205Z - Done responding to the client project-graph
   [NX Daemon Server] - 2023-05-03T11:46:21.788Z - [REQUEST]: Responding to the client. recordOutputsHash
   [NX Daemon Server] - 2023-05-03T11:46:21.789Z - Done responding to the client recordOutputsHash
   [NX Daemon Server] - 2023-05-03T11:46:21.923Z - [REQUEST]: Responding to the client. recordOutputsHash
   [NX Daemon Server] - 2023-05-03T11:46:21.923Z - Done responding to the client recordOutputsHash
   [NX Daemon Server] - 2023-05-03T11:46:21.952Z - [REQUEST]: Responding to the client. recordOutputsHash
   [NX Daemon Server] - 2023-05-03T11:46:21.952Z - Done responding to the client recordOutputsHash
   [NX Daemon Server] - 2023-05-03T11:46:23.633Z - [WATCHER]: Unsubscribed from changes within: /home/user (sources)
   [NX Daemon Server] - 2023-05-03T11:46:23.634Z - [WATCHER]: Unsubscribed from changes within: /home/user (server-process.json)
   [NX Daemon Server] - 2023-05-03T11:46:23.634Z - Server stopped because: "Stopping the daemon the set of ignored files changed."



   More information: /home/user/node_modules/.cache/nx/d/daemon.log
   Pass --verbose to see the stacktrace.

node_modules/.bin/nx run-many --all --target=build --skip-nx-cache  10.32s user 1.49s system 287% cpu 4.109 total

Additional Information

It seems that the error happens more often (not always) after a nx reset

Starting the command mulltiple times helps and after a complete run, consecutive run are successful

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 17
  • Comments: 15

Most upvoted comments

I think I have a 3rd related issue w/ the error Watch error: Daemon closed the connection occurring after every git commit since upgrading to NX 16.

I’m not really sure how to debug since --verbose gives me no error stack or additional errors. I don’t know how to access the logs from the process where the error is occurring.

I’m using executor @nx/js:node

I’m having the same issue (after moving to 16.x):

fatal: no path specified

It often (but not 100% of the time) seems to be right after a watcher line:

[WATCHER]: path/to/some/directory was created or restored
fatal: no path specified

With the @nx/js:node executor, this is not super convenient if the root cause is files changing, as it is used for the serve task… 😅 Any time a file changes, the process exits:

>  NX  File change detected. Restarting...

node:internal/errors:867
  const err = new Error(message);
              ^

Error: Command failed: taskkill /pid 16428 /T /F
ERROR: The process "16428" not found.

16.5 fixes this issue for me

I can easily reproduce it with these targets:

{
  "targets": {
    "echo": {
      "inputs": [],
      "outputs": ["{projectRoot}"],
      "dependsOn": ["non-cacheable-echo"],
      "executor": "nx:run-commands",
      "options": {
        "command": "true"
      }
    },
    "non-cacheable-echo": {
      "inputs": [],
      "outputs": ["{projectRoot}"],
      "dependsOn": ["cacheable-echo"],
      "executor": "nx:run-commands",
      "options": {
        "command": "true"
      }
    },
    "cacheable-echo": {
      "inputs": [],
      "outputs": ["{projectRoot}"],
      "executor": "nx:run-commands",
      "options": {
        "command": "true"
      }
    }
  }
}

if you run echo target at least twice - you will see the error:

>  NX   Error: write EPIPE


   Messages from the log:
   [NX Daemon Server] - 2023-09-25T11:42:25.986Z - [REQUEST]: Client Request for Project Graph Received
   [NX Daemon Server] - 2023-09-25T11:42:26.395Z - [REQUEST]: Updated file-hasher based on watched changes, recomputing project graph...
   [NX Daemon Server] - 2023-09-25T11:42:26.395Z - [REQUEST]:
   [NX Daemon Server] - 2023-09-25T11:42:26.395Z - [REQUEST]:
   [NX Daemon Server] - 2023-09-25T11:42:26.471Z - [REQUEST]: Responding to the client. project-graph
   [NX Daemon Server] - 2023-09-25T11:42:26.473Z - Time taken for 'total for creating and serializing project graph' 484.8588333129883ms
   [NX Daemon Server] - 2023-09-25T11:42:26.474Z - Done responding to the client project-graph
   [NX Daemon Server] - 2023-09-25T11:42:26.474Z - Handled REQUEST_PROJECT_GRAPH. Handling time: 485. Response time: 3.
   [NX Daemon Server] - 2023-09-25T11:42:26.522Z - [REQUEST]: Responding to the client. handleHashTasks
   [NX Daemon Server] - 2023-09-25T11:42:26.523Z - Done responding to the client handleHashTasks
   [NX Daemon Server] - 2023-09-25T11:42:26.523Z - Handled HASH_TASKS. Handling time: 34. Response time: 1.
   [NX Daemon Server] - 2023-09-25T11:42:26.617Z - [REQUEST]: Responding to the client. outputsHashesMatch
   [NX Daemon Server] - 2023-09-25T11:42:26.617Z - Done responding to the client outputsHashesMatch
   [NX Daemon Server] - 2023-09-25T11:42:26.617Z - Handled OUTPUTS_HASHES_MATCH. Handling time: 61. Response time: 0.
   [NX Daemon Server] - 2023-09-25T11:42:26.683Z - [WATCHER]: Processing file changes in outputs
   [NX Daemon Server] - 2023-09-25T11:42:26.686Z - [WATCHER]: 0 file(s) created or restored, 0 file(s) modified, 590 file(s) deleted
   [NX Daemon Server] - 2023-09-25T11:42:26.686Z - [WATCHER]: Stopping the watcher for /Users/platform (sources)
   [NX Daemon Server] - 2023-09-25T11:42:26.686Z - [WATCHER]: Stopping the watcher for /Users/platform (outputs)
   [NX Daemon Server] - 2023-09-25T11:42:26.686Z - Server stopped because: "Stopping the daemon the set of ignored files changed (native)"

I suspect it only happens if the project, you are running the target on, itself has a .gitignore file in it’s root. So while it tries to replace .gitignore file with the same one - it triggers some event, which causes the error.

Have the same issue after upgrading nx to 16.4.0 even in a CI, though Nx Daemon should be disabled by default in a CI environment as described in the docs https://nx.dev/more-concepts/nx-daemon#turning-it-off

Not sure but on my side it looks like a combination of the @nx/node executor and the Webstorm “Nx Console” plugin (on windows). When i disable the plugin and run it with the command, it runs correctly, but if i turn the plugin on again it closes the existing serve process started with @nx/node.