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

Sometimes nx run-many --parrallel --target=build command crashes due NX Daemon Server #18962

Closed
1 of 4 tasks
NaumovEvgeniy opened this issue Sep 1, 2023 · 9 comments
Closed
1 of 4 tasks
Assignees
Labels

Comments

@NaumovEvgeniy
Copy link

Current Behavior

I have two apps: front (vue3) and backend (nest)

I want to build all of them. Exec nx run-many --parallel --target=build --skip-nx-cache. Sometimes build is passed, sometimes build throws an error

 >  NX   Unable to connect to the daemon process.

   
   Messages from the log:
   [NX Daemon Server] - 2023-09-01T09:57:45.226Z - Established a connection. Number of open connections: 1
   [NX Daemon Server] - 2023-09-01T09:57:45.228Z - Closed a connection. Number of open connections: 0
   [NX Daemon Server] - 2023-09-01T09:57:45.229Z - Established a connection. Number of open connections: 1
   [NX Daemon Server] - 2023-09-01T09:57:45.230Z - [REQUEST]: Client Request for Project Graph Received
   [NX Daemon Server] - 2023-09-01T09:57:45.231Z - [REQUEST]: Responding to the client. project-graph
   [NX Daemon Server] - 2023-09-01T09:57:45.232Z - Time taken for 'total for creating and serializing project graph' 0.17211499996483326ms
   [NX Daemon Server] - 2023-09-01T09:57:45.233Z - Done responding to the client project-graph
   [NX Daemon Server] - 2023-09-01T09:57:45.233Z - Handled REQUEST_PROJECT_GRAPH. Handling time: 0. Response time: 3.
   [NX Daemon Server] - 2023-09-01T09:57:45.270Z - [REQUEST]: Responding to the client. handleHashTasks
   [NX Daemon Server] - 2023-09-01T09:57:45.271Z - Done responding to the client handleHashTasks
   [NX Daemon Server] - 2023-09-01T09:57:45.271Z - Handled HASH_TASKS. Handling time: 22. Response time: 1.
   [NX Daemon Server] - 2023-09-01T09:57:46.998Z - [WATCHER]: src/apps/front/vite.config.ts.timestamp-1693562266947-531465b1fb7da.mjs was created or restored
   [NX Daemon Server] - 2023-09-01T09:57:46.999Z - [WATCHER]: Processing file changes in outputs
   [NX Daemon Server] - 2023-09-01T09:57:47.107Z - [REQUEST]: Updated file-hasher based on watched changes, recomputing project graph...
   [NX Daemon Server] - 2023-09-01T09:57:47.107Z - [REQUEST]: 761713782931888045
   [NX Daemon Server] - 2023-09-01T09:57:47.107Z - [REQUEST]: 
   thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', packages/nx/src/native/plugins/js/ts_import_locators.rs:450:10
   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
   fatal runtime error: failed to initiate panic, error 5

The daemon.log was attached
daemon.log

Separately call of build tasks completes successfully

Expected Behavior

Successful build all of applications

GitHub Repo

No response

Steps to Reproduce

  1. Exec nx run-many --parrallel --target=build

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 18.16.0
   OS     : linux-x64
   npm    : 9.5.1
   
   nx                 : 16.7.4
   @nx/js             : 16.7.4
   @nx/jest           : 16.7.4
   @nx/linter         : 16.7.4
   @nx/workspace      : 16.7.4
   @nx/devkit         : 16.7.4
   @nx/eslint-plugin  : 16.7.4
   @nx/nest           : 16.7.4
   @nx/node           : 16.7.4
   @nrwl/tao          : 16.7.4
   @nx/vite           : 16.7.4
   @nx/webpack        : 16.7.4
   typescript         : 5.1.6

Failure Logs

No response

Package Manager Version

npm 9.5.1

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@AgentEnder AgentEnder added the scope: core core nx functionality label Sep 5, 2023
@Cammisuli Cammisuli self-assigned this Sep 5, 2023
@Cammisuli
Copy link
Member

hey @NaumovEvgeniy do you have a repo I can pull down that shows this happening?

@alainfonhof
Copy link

alainfonhof commented Sep 6, 2023

Having the same issue with the same node and npm version. Unfortunately don't have any public repo to share.

@alainfonhof
Copy link

After downgrading to 16.6.0 the Daemon doesn't crash anymore. Starting with 16.7.0 the issue seems to arise.

@Cammisuli
Copy link
Member

Cammisuli commented Sep 6, 2023

How many libraries are dependencies on the app that's being built? Are they buildable libraries if there are any?

Having some kind of a minimal reproduction would be very helpful for me, because I can't reproduce this locally 😮

@alainfonhof
Copy link

It seems to be related to vitest and running the tests in parallel. Running the tests with parallel=1 prevents the Daemon from crashing.

@lorenzodejong
Copy link

lorenzodejong commented Sep 7, 2023

Just investigated this in our project. Judging from the logs we were running into the same issues as you @NaumovEvgeniy.

You're likely using a vite.config.mts in your project. When executing this .mts file Vite/Vitest actually transpiles this to a .mjs file when executing your tests. This will trigger the Nx file watcher, in turn recomputing the entire project graph, which is why you see the following logs:

   [NX Daemon Server] - 2023-09-01T09:57:46.998Z - [WATCHER]: src/apps/front/vite.config.ts.timestamp-1693562266947-531465b1fb7da.mjs was created or restored
   [NX Daemon Server] - 2023-09-01T09:57:46.999Z - [WATCHER]: Processing file changes in outputs
   [NX Daemon Server] - 2023-09-01T09:57:47.107Z - [REQUEST]: Updated file-hasher based on watched changes, recomputing project graph...

This works fine when running nx run-many --parallel 1, however when parallelising more tasks at once these recomputations cause the Nx daemon to crash.

In order to solve this we actually changed vite.config.mts to vite.config.ts. Since this will likely raise some issues with the types, we also had to change the following:

  • tsconfig.json: add vite.config.ts to the exclude array
  • tsconfig.spec.json: add vite.config.ts to the include array, change compilerOptions.moduleResolution to nodenext

This will make sure your Vite config can be executed directly using ESM, which prevents the .mts files from being transpiled when running your Nx targets.

@Cammisuli
Copy link
Member

hmm. Ok, I'll give it a shot with vitest and see whats up.

@NaumovEvgeniy
Copy link
Author

Guys, thanks for help, but I have switched to another project and I can't track this issue

@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 Oct 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants