nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.66k stars 2.36k forks source link

> NX Passed 7460 file paths to Git to hash, but received 1709 hashes. #8779

Closed SynergyEvolved closed 2 years ago

SynergyEvolved commented 2 years ago

Current Behavior

Sometimes I get the following error when running my nestjs nx apps. I have 8 apps and when I try to run them all at once a few of them fail. Re-running the app succeeds.

>  NX   Passed 7460 file paths to Git to hash, but received 1709 hashes.

I have tried nx reset and it doesnt fix it it. I have tried disabling the nx daemon with

 "tasksRunnerOptions": {
        "default": {
            "runner": "@nrwl/workspace/tasks-runners/default",
            "options": {
                "cacheableOperations": ["build", "lint", "test", "e2e"],
                "useDaemonProcess": false
            }
        }
    },

and it doesnt fix it. Neither does NX_DAEMON=false in the .env file.

Yes it worked before I upgraded to the latest NX.

Environment

NX Report complete - copy this into the issue template

Node : 16.13.1 OS : linux x64 yarn : 1.22.17

nx : 13.7.1 @nrwl/angular : 13.7.1 @nrwl/cli : 13.7.1 @nrwl/cypress : 13.7.1 @nrwl/detox : undefined @nrwl/devkit : 13.7.1 @nrwl/eslint-plugin-nx : 13.7.1 @nrwl/express : undefined @nrwl/jest : 13.7.1 @nrwl/js : undefined @nrwl/linter : 13.7.1 @nrwl/nest : 13.7.1 @nrwl/next : undefined @nrwl/node : 13.7.1 @nrwl/nx-cloud : undefined @nrwl/react : undefined @nrwl/react-native : undefined @nrwl/schematics : undefined @nrwl/storybook : 13.7.1 @nrwl/tao : 13.7.1 @nrwl/web : undefined @nrwl/workspace : 13.7.1 typescript : 4.5.5 rxjs : 6.6.7

Community plugins: @angular/animations: 13.2.0 @angular/common: 13.2.0 @angular/compiler: 13.2.0 @angular/core: 13.2.0 @angular/forms: 13.2.0 @angular/platform-browser: 13.2.0 @angular/platform-browser-dynamic: 13.2.0 @angular/router: 13.2.0 apollo-angular: 2.6.0 @angular-devkit/build-angular: 13.2.0 @angular/cli: 13.2.0 @angular/compiler-cli: 13.2.0 @angular/language-service: 13.2.0

Thanks for your help! -Paul

tomaszwawrzyniakit commented 2 years ago

Same for me. Nothing helps, always 0 hashes. I need to stay with 13.5.3.

`Failed to start the Nx Daemon process. Messages from the log:

NX Passed 14 file paths to Git to hash, but received 0 hashes.

NX Passed 14 file paths to Git to hash, but received 0 hashes.

NX Passed 14 file paths to Git to hash, but received 0 hashes.

NX Passed 15 file paths to Git to hash, but received 0 hashes.

NX Passed 15 file paths to Git to hash, but received 0 hashes.

NX Passed 17 file paths to Git to hash, but received 0 hashes. `


Update:

It looks like it was fixed with 13.7.2.

SynergyEvolved commented 2 years ago

Git add . seems to fix.

FrozenPandaz commented 2 years ago

It looks like it was fixed with 13.7.2.

Glad this is resolved. :smile:

SynergyEvolved commented 2 years ago

If 'git add .' is required for the app to start up, then shouldn't it be included in the docs somewhere?

sorin-davidoi commented 2 years ago

This is most likely a race condition in https://github.com/nrwl/nx/blob/33c9ca98ae6940befb8e1132cb2263adb99ce5bc/packages/workspace/src/core/hasher/git-hasher.ts#L5-L39

It checks if the files exist before passing them to git hash-object, but the files might get deleted by another process after the check and before hashing starts.

git hash-object will complain about this and fail with a reasonable error message printed to stderr, but https://github.com/nrwl/nx/blob/33c9ca98ae6940befb8e1132cb2263adb99ce5bc/packages/workspace/src/core/hasher/git-hasher.ts#L41-L52 checks neither the return code nor what is printed to stderr, so getGitHashForFiles fails with a very generic error message instead of actually showing which files couldn't be hashed (and why).

jankanty commented 2 years ago

It looks like it was fixed with 13.7.2.

Glad this is resolved. 😄

What if it wasn't? I'm using 13.8.3 and it still occurs randomly.

SynergyEvolved commented 2 years ago

I get the error when lots of files are changing, like a prisma generator. I suggest you create a new issue as I don't think they check closed ones, of maybe @FrozenPandaz can re-open this one?

pwespi commented 2 years ago

I had the same error in a GitLab CI pipeline. The reason was that we use npm ci --cache .npm --prefer-offline to install the dependencies, but .npm was not in .gitignore. Adding .npm to .gitignore solved it for us. Maybe this will help someone else with a similar problem.

jonhamm commented 2 years ago

I have seen same problem in our Jenkins builds -- could not find a pattern as to when it happens I am on 13.9.5

jonhamm commented 2 years ago

I now realised this is a node 16.14.2 induced problem

In this setting I do get the error immediately


 >  NX   Report complete - copy this into the issue template

   Node : 16.14.2
   OS   : darwin x64
   npm  : 8.5.0

   nx : 13.8.0
   @nrwl/angular : 13.8.0
   @nrwl/cli : 13.8.0
   @nrwl/cypress : 13.8.0
   @nrwl/detox : undefined
   @nrwl/devkit : 13.8.0
   @nrwl/eslint-plugin-nx : 13.8.0
   @nrwl/express : undefined
   @nrwl/jest : 13.8.0
   @nrwl/js : undefined
   @nrwl/linter : 13.8.0
   @nrwl/nest : undefined
   @nrwl/next : undefined
   @nrwl/node : undefined
   @nrwl/nx-cloud : 13.1.4
   @nrwl/react : undefined
   @nrwl/react-native : undefined
   @nrwl/schematics : undefined
   @nrwl/storybook : 13.8.0
   @nrwl/tao : 13.8.0
   @nrwl/web : undefined
   @nrwl/workspace : 13.8.0
   typescript : 4.5.5
   rxjs : 6.6.7
   ---------------------------------------
   Community plugins:
     @angular/animations: 13.2.2
     @angular/cdk: 13.2.1
     @angular/common: 13.2.2
     @angular/compiler: 13.2.2
     @angular/core: 13.2.2
     @angular/forms: 13.2.2
     @angular/platform-browser: 13.2.2
     @angular/platform-browser-dynamic: 13.2.2
     @angular/router: 13.2.2
     @angular/upgrade: 13.2.2
     @ngrx/component-store: 13.0.2
     @ngrx/store: 13.0.2
     @ngx-matomo/tracker: 2.4.1
     apollo-angular: 2.6.0
     @angular-builders/custom-webpack: 13.1.0
     @angular-devkit/build-angular: 13.2.2
     @angular/cli: 13.2.2
     @angular/compiler-cli: 13.2.2
     @angular/elements: 13.2.2
     @angular/language-service: 13.2.2
     @compodoc/compodoc: 1.1.19
     @storybook/angular: 6.4.22
     @testing-library/angular: 10.11.1
     ng-mocks: 13.4.2
     nx-stylelint: 12.3.1

But in this setting which is similar except for the node version there is no problem


 >  NX   Report complete - copy this into the issue template

   Node : 14.17.6
   OS   : darwin x64
   npm  : 6.14.15

   nx : undefined
   @nrwl/angular : 13.8.0
   @nrwl/cli : 13.8.0
   @nrwl/cypress : 13.8.0
   @nrwl/detox : undefined
   @nrwl/devkit : 13.8.0
   @nrwl/eslint-plugin-nx : 13.8.0
   @nrwl/express : undefined
   @nrwl/jest : 13.8.0
   @nrwl/js : undefined
   @nrwl/linter : 13.8.0
   @nrwl/nest : undefined
   @nrwl/next : undefined
   @nrwl/node : undefined
   @nrwl/nx-cloud : 13.1.4
   @nrwl/react : undefined
   @nrwl/react-native : undefined
   @nrwl/schematics : undefined
   @nrwl/storybook : 13.8.0
   @nrwl/tao : 13.8.0
   @nrwl/web : undefined
   @nrwl/workspace : 13.8.0
   typescript : 4.5.5
   rxjs : 6.6.7
   ---------------------------------------
   Community plugins:
     @angular/animations: 13.2.2
     @angular/cdk: 13.2.1
     @angular/common: 13.2.2
     @angular/compiler: 13.2.2
     @angular/core: 13.2.2
     @angular/forms: 13.2.2
     @angular/platform-browser: 13.2.2
     @angular/platform-browser-dynamic: 13.2.2
     @angular/router: 13.2.2
     @angular/upgrade: 13.2.2
     @ngrx/component-store: 13.0.2
     @ngrx/store: 13.0.2
     @ngx-matomo/tracker: 2.4.1
     apollo-angular: 2.6.0
     @angular-builders/custom-webpack: 13.1.0
     @angular-devkit/build-angular: 13.2.2
     @angular/cli: 13.2.2
     @angular/compiler-cli: 13.2.2
     @angular/elements: 13.2.2
     @angular/language-service: 13.2.2
     @compodoc/compodoc: 1.1.19
     @storybook/angular: 6.4.22
     @testing-library/angular: 10.11.1
     ng-mocks: 13.4.2
     nx-stylelint: 12.3.1
julianpoemp commented 2 years ago

I get this error with Nx 14.1.7, too. The only workaround I found is to restart my computer. Does anyone knows a fix?

hwanders commented 2 years ago

We had a similar problem on a Windows 10 system. It turned out, the actual problem were file paths which exceeded the length of 260 characters. Shortening the paths fixed the problem. Perhaps setting the registry setting LongPathsEnabled helps too.

github-actions[bot] commented 1 year ago

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.