nrwl / nx

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

Running NX_BATCH_MODE with test gets stuck #8963

Closed meeroslav closed 2 years ago

meeroslav commented 2 years ago

Running the following command produces flashing of the logger content until it eventually gets stuck as seen in the following video (cc @JamesHenry):

NX_BATCH_MODE=true npx nx run-many --target=test --all --skip-nx-cache

https://user-images.githubusercontent.com/881612/153916408-4a2d6038-46ef-4ebe-b89c-9ac8b58a9178.mov

while running it without skip-nx-cache breaks with:

Unexpected error:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:371:5)
    at validateString (node:internal/validators:119:11)
    at join (node:path:1172:7)
    at Cache.<anonymous> (/Users/.../node_modules/@nrwl/workspace/src/tasks-runner/cache.js:230:40)
    at Generator.next (<anonymous>)
    at /Users/.../node_modules/tslib/tslib.js:117:75
    at new Promise (<anonymous>)
    at __awaiter (/Users/.../node_modules/tslib/tslib.js:113:16)
    at Cache.getFromLocalDir (/Users/.../node_modules/@nrwl/workspace/src/tasks-runner/cache.js:228:38)
    at Cache.<anonymous> (/Users/.../node_modules/@nrwl/workspace/src/tasks-runner/cache.js:43:36) {
  code: 'ERR_INVALID_ARG_TYPE'

Current Behavior

Run gets broken

Expected Behavior

Using NX_BATCH_MODE should not produce errors.

Steps to Reproduce

The angular repository consists of 15 projects (6 apps, 9 libs), a small number of unit tests. It uses angular.json and has standard tsconfig.spec.json and jest.config.js files (copied from default generated Nx repo)

module.exports = {
  name: 'my-app-name',
  preset: '../../jest.preset.js',
  coverageDirectory: '../../coverage/app/my-app-name',
  setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
  globals: {
    'ts-jest': {
      tsconfig: '<rootDir>/tsconfig.spec.json',
      stringifyContentPathRegex: '\\.(html|svg)$',
    },
  },
  transform: {
    '^.+\\.(ts|mjs|js|html)$': 'jest-preset-angular',
  },
  transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
  snapshotSerializers: [
    'jest-preset-angular/build/serializers/no-ng-attributes',
    'jest-preset-angular/build/serializers/ng-snapshot',
    'jest-preset-angular/build/serializers/html-comment',
  ],
};
{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "../../dist/out-tsc",
    "module": "commonjs",
    "types": ["jest", "node"]
  },
  "files": ["src/test-setup.ts"],
  "include": ["**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"]
}

Environment

Node : 16.11.1 OS : darwin arm64 npm : 8.0.0

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

Community plugins: @angular/animations: 13.2.1 @angular/cdk: 13.2.1 @angular/common: 13.2.1 @angular/compiler: 13.2.1 @angular/core: 13.2.1 @angular/forms: 13.2.1 @angular/material: 13.2.1 @angular/platform-browser: 13.2.1 @angular/platform-browser-dynamic: 13.2.1 @angular/router: 13.2.1 @ngrx/component-store: 13.0.1 ngx-ui-loader: 11.0.0 @angular-devkit/architect: 0.1302.2 @angular-devkit/build-angular: 13.2.2 @angular-eslint/builder: 13.0.1 @angular-eslint/schematics: 13.0.1 @angular/cli: 13.2.2 @angular/compiler-cli: 13.2.1 @angular/language-service: 13.2.1

guiseek commented 2 years ago

same here

Use case

➜  guiseek git:(main) ✗ nx affected:test 

 >  NX   Affected criteria defaulted to --base=main --head=HEAD

    ✔  nx run shared-infra:test (3s)

 ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Running target test for 1 projects

    ✔    1/1 succeeded [0 read from cache]

Unexpected error:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:371:5)
    at validateString (node:internal/validators:120:11)
    at join (node:path:1172:7)
    at CloudEnabledLifeCycle.getTerminalOutput (/Users/guiseek/workspaces/guiseek/node_modules/@nrwl/nx-cloud/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js:1:4335)
    at CloudEnabledLifeCycle.updateStartedTask (/Users/guiseek/workspaces/guiseek/node_modules/@nrwl/nx-cloud/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js:1:3963)
    at CloudEnabledLifeCycle.endTasks (/Users/guiseek/workspaces/guiseek/node_modules/@nrwl/nx-cloud/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js:1:3339)
    at CompositeLifeCycle.endTasks (/Users/guiseek/workspaces/guiseek/node_modules/nx/src/tasks-runner/life-cycle.js:56:19)
    at TaskOrchestrator.<anonymous> (/Users/guiseek/workspaces/guiseek/node_modules/nx/src/tasks-runner/task-orchestrator.js:235:36)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/guiseek/workspaces/guiseek/node_modules/tslib/tslib.js:115:62) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Report

➜  guiseek git:(main) ✗ nx report       

 >  NX   Report complete - copy this into the issue template

   Node : 16.14.0
   OS   : darwin arm64
   npm  : 8.3.1

   nx : 14.3.5
   @nrwl/angular : Not Found
   @nrwl/cypress : 14.3.5
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.3.5
   @nrwl/eslint-plugin-nx : 14.3.5
   @nrwl/express : Not Found
   @nrwl/jest : 14.3.5
   @nrwl/js : 13.9.5
   @nrwl/linter : 14.3.5
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : 14.1.1
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : 13.9.5
   @nrwl/workspace : 14.3.5
   typescript : 4.7.3
   ---------------------------------------
   Community plugins:
         @nxext/solid: 14.0.0
guiseek commented 2 years ago

I removed the "accessToken" from the configuration in the nx.json file, so the problem doesn't happen. in my case it seems to be related to nx-cloud package

meeroslav commented 2 years ago

Hey @guiseek thank you for reviving this issue and reminding me I should close it. The issues you are experiencing is definitely not related to this one, so please open a new issue with your comment.

Thank you!

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.