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

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

Closed
Jejuni opened this issue Jun 20, 2022 · 43 comments · Fixed by #14965
Closed
Assignees
Labels
os: windows Issues that can only be replicated on Windows outdated scope: core core nx functionality type: bug

Comments

@Jejuni
Copy link

Jejuni commented Jun 20, 2022

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:
@AgentEnder AgentEnder added the scope: core core nx functionality label Jun 21, 2022
@PointSingularity
Copy link

This also happens to me. The curious thing is that with the NX Console Plugin installed it spawns a window for the error, but if the extension is disabled it only shows an error inside VSCode. It also stops showing after some time, after VSCode is closed and opened again.

PowerShell Core 7.2.5
Windows 11 22H2
VSCode 1.68.1
Node: 18.4.0
npm 8.12.2
"@nrwl/angular": "^14.3.6",
"@nrwl/cli": "14.3.6",
"@nrwl/cypress": "14.3.6",
"@nrwl/eslint-plugin-nx": "14.3.6",
"@nrwl/express": "^14.3.6",
"@nrwl/jest": "14.3.6",
"@nrwl/linter": "14.3.6",
"@nrwl/node": "14.3.6",
"@nrwl/workspace": "14.3.6",

@NordlingDev
Copy link

NordlingDev commented Jul 1, 2022

This happens to me too. Since that one node process is never killed after build script, it blocks the dist folder from being rewritten on next build script. Apparently NX thinks the project has no changes made, so it skips building and uses the one from cache - thus leaving you with an outdated build. To fix that you have to manually kill the remaining node process.

NX report:

Node : 16.12.0
OS   : win32 x64
yarn : 1.22.17

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

@FrozenPandaz
Copy link
Collaborator

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.

@PointSingularity
Copy link

PointSingularity commented Jul 29, 2022

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

deamon.mp4

@github-actions
Copy link

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Aug 13, 2022
@unlight
Copy link

unlight commented Aug 13, 2022

Not a stale.

@github-actions github-actions bot removed the stale label Aug 14, 2022
@PointSingularity
Copy link

PointSingularity commented Aug 23, 2022

@FrozenPandaz
Windows just gave me this popup, I don't think it is related, just wanted to document it.
image

You can check my exact setup here in the video

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
deamon.mp4

@Jejuni
Copy link
Author

Jejuni commented Sep 6, 2022

Also now having the same problems as #11247
After using nx generator to add libs / components. 8-10 console windows open and then immediately close again.
That was probably there from the beginning, but I haven't used the generators in a while.

Also recently upgraded to node 16.17.0, but problem still persists.

@Jejuni
Copy link
Author

Jejuni commented Sep 6, 2022

I've spent some more time analyzing the problem.

When navigating to an Nx Project and running nx daemon --start the same problem as described initially appears. That is, a console window spawns that simply states [process exited with code 1 (0x00000001)].
Running nx daemon after that, however, prints Nx Daemon is currently running: and then a link to the logs and a ProcessId.

Using nx daemon --start --background=false to run the daemon in the current process does NOT produce any errors or popups.

I've also tried debugging the daemon.js, but since the error only happens when the code that causes the error runs in the background I've not gotten very far.

@FrozenPandaz does any of this help with troubleshooting the issue on your side?

@github-actions
Copy link

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Sep 21, 2022
@PointSingularity
Copy link

Not stale.

@github-actions github-actions bot removed the stale label Sep 22, 2022
@github-actions
Copy link

github-actions bot commented Oct 6, 2022

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Oct 6, 2022
@Jejuni
Copy link
Author

Jejuni commented Oct 8, 2022

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.

@github-actions github-actions bot removed the stale label Oct 9, 2022
@github-actions
Copy link

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Oct 23, 2022
@rainerhahnekamp
Copy link

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.

@github-actions github-actions bot removed the stale label Oct 24, 2022
@github-actions
Copy link

github-actions bot commented Nov 8, 2022

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Nov 8, 2022
@tfrijsewijk
Copy link

I also have the Command Prompt Pinata 🪅, but I even have it when saving a file that's monitored by Nx.. It's driving me crazy 🤯

@raeffs
Copy link

raeffs commented Dec 29, 2022

I have the same problem when working in VSCode on Windows 11. It always opens up terminal windows that close again immediately but as they steal focus it is basically not possible to work with it.

@jbadeau
Copy link

jbadeau commented Jan 26, 2023

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. 😿

@jbadeau
Copy link

jbadeau commented Jan 26, 2023

Out of curiosity

  1. what node package manager is everyone using?
  2. Are u using workspaces?

Yarn:yes

@michaelbromley
Copy link

@jbadeau Yes, yarn v1.22.19, with workspaces (via Lerna)

@raeffs
Copy link

raeffs commented Jan 26, 2023

I have it with npm and yarn. Not using workspaces. It also seems not related to vscode, the popups also pop up when using nx commands in the terminal.

@Jejuni
Copy link
Author

Jejuni commented Jan 27, 2023

Npm v8.19.2 with workspaces, problem happens in vs-code, WebStorm, and just regular terminal

@itspers
Copy link

itspers commented Feb 2, 2023

i think its one process per lib in this daemon or so...

nx.mp4

@JakeAi
Copy link

JakeAi commented Feb 6, 2023

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

@whjacobsen
Copy link

We are also experiencing this, and we use latest:

  • NX: 15.6.3
  • NX console: 17.29.0
  • node: 18.14.0 (The issue was also on node: 16.16.0)
  • yarn: 1.22.19
  • VS Code on Windows: 1.75.0

@JakeAi
Copy link

JakeAi commented Feb 9, 2023

@meeroslav @Coly010 can this get looked into? A lot of people are experiencing this.

@Coly010 Coly010 added the os: windows Issues that can only be replicated on Windows label Feb 9, 2023
@meeroslav
Copy link
Contributor

meeroslav commented Feb 10, 2023

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.

@JamesHenry
Copy link
Collaborator

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

@krokofant
Copy link

I assume that this is caused by the child_process calls to spawn with the detached option. The windowsHide option does not seem to do anything when detached option is used on Windows. (packages\nx\src\daemon\client\client.ts)

@PointSingularity
Copy link

PointSingularity commented Feb 10, 2023

Just FYI, this also happens with the NX Console VSCode plugin.
So even if you have the deamon turned off, if you have the plugin enabled it spawns a console, for example when you start VSCode and the plugins are initializing.

Here is a short video of enabling the plugin:

nx.console.mp4
 >  NX   Report

   Node : 18.13.0
   OS   : win32 x64
   npm  : 9.3.1
   
   nx : 15.6.3
   @nrwl/angular : Not Found
   @nrwl/cypress : 15.6.3
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.6.3
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 15.6.3
   @nrwl/expo : Not Found
   @nrwl/express : 15.6.3
   @nrwl/jest : 15.6.3
   @nrwl/js : 15.6.3
   @nrwl/linter : 15.6.3
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : 15.6.3
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 15.6.3
   @nrwl/react-native : Not Found
   @nrwl/rollup : 15.6.3
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : 15.6.3
   @nrwl/webpack : 15.6.3
   @nrwl/workspace : 15.6.3
   @nrwl/vite : Not Found
   typescript : 4.9.5
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:

@Cammisuli Cammisuli self-assigned this Feb 10, 2023
@Cammisuli
Copy link
Member

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 🙂

@Cammisuli
Copy link
Member

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.

@PointSingularity
Copy link

@Cammisuli sadly this problem is back in the newest version, also if the NX Console extension is disabled popups happen less frequently :\

Node : 18.15.0
   OS   : win32 x64
   npm  : 9.6.1

   nx                      : 15.8.6
   @nrwl/js                : 15.8.6
   @nrwl/jest              : 15.8.6
   @nrwl/linter            : 15.8.6
   @nrwl/workspace         : 15.8.6
   @nrwl/cli               : 15.8.6
   @nrwl/cypress           : 15.8.6
   @nrwl/devkit            : 15.8.6
   @nrwl/eslint-plugin-nx  : 15.8.6
   @nrwl/express           : 15.8.6
   @nrwl/node              : 15.8.6
   @nrwl/react             : 15.8.6
   @nrwl/rollup            : 15.8.6
   @nrwl/tao               : 15.8.6
   @nrwl/web               : 15.8.6
   @nrwl/webpack           : 15.8.6
   typescript              : 4.9.5

NX Console version: 17.32.0

Funnily enough, it works perfectly in 15.8.5.

It can be easily reproduced by creating a new NX Node Standalone app, and running 'npm run start':
image

The problem doesn't exist if the app is created with the 15.8.5 version.

Also, I keep getting 'Watch error: Daemon closed the connection' when running 'npm run start', but not sure if that is related to the same problem.

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
os: windows Issues that can only be replicated on Windows outdated scope: core core nx functionality type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.