nx: Error Popup on every nx command (probably from node_modules\nx\src\daemon\server\start.js)

Current Behavior

When running any nx command, like nx run my-app:build or nx run my-app:test for the first time (after a reboot, for instance) a cmd window pops up, simply stating [process exited with code 1 (0x00000001)]:

image

The run still seemingly completes correctly. After that every subsequent run of any nx command completes without error.

On closer inspection I found that a node process is spawned and called with the following arguments:

"C:\Program Files\nodejs\node.exe" C:\my-workspace\node_modules\nx\src\daemon\server\start.js

This process persists even after closing the terminal. Killing this process manually and then running any nx command makes the error come back.

Expected Behavior

No cmd windows with errors pop up.

Steps to Reproduce

This was encountered on a Windows machine version 21H2 (OS Build 22000.739). Used shell was PowerShell Core 7.2.4 AND regular PowerShell 5.1.22000.653

Repro:

  • run npx create-nx-workspace@latest test-workspace, choose angular and scss and cloud integration.
  • run nx run my-app:test
  • Error should appear

Environment

nx report of created workspace:

Node : 16.15.0
OS   : win32 x64
npm  : 8.5.5

nx : 14.3.6
@nrwl/angular : 14.3.6
@nrwl/cypress : 14.3.6
@nrwl/detox : Not Found
@nrwl/devkit : 14.3.6
@nrwl/eslint-plugin-nx : 14.3.6
@nrwl/express : Not Found
@nrwl/jest : 14.3.6
@nrwl/js : 14.3.6
@nrwl/linter : 14.3.6
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/nx-cloud : 14.1.2
@nrwl/nx-plugin : Not Found
@nrwl/react : Not Found
@nrwl/react-native : Not Found
@nrwl/schematics : Not Found
@nrwl/storybook : 14.3.6
@nrwl/web : 14.3.6
@nrwl/workspace : 14.3.6
typescript : 4.7.4
---------------------------------------
Community plugins:

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 16
  • Comments: 43 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Oh, I want to clarify that there was no issue with the @parcel/watcher package. I found the issue that I was coming across that was only in the Nx repo. I’ll have a PR up to fix this soon.

Hey all, I found the root cause of this. And it comes in two parts:

  1. We use a implementation that calls git to do some file hashing within the daemon (even outside the daemon, but only once or twice). And here, we missed a detached: true in that spawn call.
  2. We also use the @parcel/watcher package, and appears to do some spawning in the background whenever files change. (This is why some folks are seeing dozens of pop ups because dozens of changes are happening). I’m going to investigate this one a little bit more to see if we can do some configuration on our side before I make an issue on their board.

We’re really sorry that it’s taken this long to come to a root cause, and thank you everyone for your patience and understanding.

The light is visible at the end of this tunnel 🙂

It happens to me as well and it’s driving me insane

Not a stale.

I can only agree with @Jejuni. It has become worse on Windows. It would be great if you can fix that. Please do not stale.

I haven’t been involved in the daemon for a long time I’m afraid so can’t comment further. Rest assured folks this is a top priority for the team to resolve, please follow Miro’s advice about disabling the daemon in the meantime

Not stale.

Sorry for this persistent annoying problem. You can switch off daemon by setting the env variable NX_DAEMON=false which will stop the daemon from being started. Unfortunately, you will also lose all the benefits. The daemon runs in the background and recalculates the project graph on every change so that when you run the nx command in the terminal or within your IDE (e.g. eslint) the graph is already up to date and there is no cold start or graph mismatch (in case of IDE).

But based on your reports, it seems that the daemon is crashing anyway so you wouldn’t lose much.

Perhaps @JamesHenry can provide more information as he was the original author of that functionality.

This issue is really embarrassing when trying to promote nx in a demo or so. Kills my machine with popups. I’m now afraid to demo anything nx on windows. 😿

Not stale.

Not stale, and has gotten much worse with the last update.

As far as I can see, the --background=false flag does not exists/work anymore. I couldn’t find any reference to it in the docs or nx daemon help anymore and using the flag still tries to run the daemon in a background process.

All my colleagues are having the same problem on their windows machines. There’s no way to work with the nx daemon in its current state and the only course of action is to just disable it.

Please take another look at the problem.

We have tried to reproduce this but have not been able to. 😞

In #11247, the user was using the newer Windows Terminal but here I see people are using Powershell + Powershell Core 🤔

If anybody else has information that might help us reproduce this, please share! We will continue to try to reproduce it with any additional information provided.

I also posted above. I am on Windows 11, with Windows Terminal, PowerShell 7.2.5. I solved the issue with the popup by disabling the “daemon” in nx.json:

nx.json
...
 "tasksRunnerOptions": {
    "default": {
      "runner": "nx/tasks-runners/default",
      "options": {
        "cacheableOperations": ["build", "lint", "test", "e2e"],
        "useDaemonProcess": false
      }
    }
  }, 
...

I hope this can shine some light on the problem, but I think this is more of a workaround than a full solution.

Edit: I just tried creating a new nx workspace, with a base angular app. When I open the project in VSCode, the terminal window opens up immediately with the error.

Install finishes at around 2:30

https://user-images.githubusercontent.com/56246797/181847367-911582cf-78cd-42b0-89e9-96982cd393e0.mp4