nx: affected: commands break in 8.10.0

Expected Behavior

Updating from 8.9.0 to 8.10.0 to have no breaking changes and scripts execute same as before without modification, or to receive a meaningful error message.

Current Behavior

Any commands for affected files ( affected:test, affected:lint, affected:apps) now produce an identical error after updating to latest

Failure Information (for bugs)

> nx affected:test

...\node_modules\@nrwl\workspace\node_modules\yargs\yargs.js:1109
      else throw err
           ^

TypeError: Cannot read property 'name' of undefined
    at ProjectGraphBuilder.addNode (...\node_modules\@nrwl\workspace\src\core\project-graph\project-graph-builder.js:15:25)
    at addAffectedNodes (...\node_modules\@nrwl\workspace\src\core\affected-project-graph\affected-project-graph.js:39:13)
    at ...\node_modules\@nrwl\workspace\src\core\affected-project-graph\affected-project-graph.js:33:9
    at Array.forEach (<anonymous>)
    at filterAffectedProjects (...\node_modules\@nrwl\workspace\src\core\affected-project-graph\affected-project-graph.js:32:25)
    at Object.filterAffected (...\node_modules\@nrwl\workspace\src\core\affected-project-graph\affected-project-graph.js:21:12)
    at Object.affected (...\node_modules\@nrwl\workspace\src\command-line\affected.js:19:36)
    at Object.handler (...\node_modules\@nrwl\workspace\src\command-line\nx-commands.js:66:138)
    at Object.runCommand (...\node_modules\@nrwl\workspace\node_modules\yargs\lib\command.js:235:44)
    at Object.parseArgs [as _parseArgs] (...\node_modules\@nrwl\workspace\node_modules\yargs\yargs.js:1022:30)

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. run ng update @nrwl/workspace to go from 8.9.0 to 8.10.0
  2. from feature branch run nx affected:test and receive error

Context

Please provide any relevant information about your setup:

  • Nx 8.10.0
  • Angular 8.2.14
  • npm 6.13.1
  • node 13.3.0

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 12
  • Comments: 24 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I’ll take a look. It will be patched in the next release.

@jaysoo Any estimate on when we can expect a release with this fix? This is halting our CICD pipeline.

@raheelriax problem will be solved if getTouchedNpmPackages stops returns packages which were removed.

JsonChange has a type field so you can check it.

Link to getTouchedNpmPackages: https://github.com/nrwl/nx/blob/e41b448085/packages/workspace/src/core/affected-project-graph/locators/npm-packages.ts#L17

I don’t know what side effects this change can bring. But at least this is a good starting point

I get maximum call stack exceeded:

yarn run v1.21.1
$ nx affected:lint
/.../node_modules/yargs/yargs.js:1133
      else throw err
           ^

RangeError: Maximum call stack size exceeded
    at /.../node_modules/@nrwl/workspace/src/core/affected-project-graph/affected-project-graph.js:42:20
    at Array.forEach (<anonymous>)
    at addAffectedNodes (/.../node_modules/@nrwl/workspace/src/core/affected-project-graph/affected-project-graph.js:42:12)
    at /.../node_modules/@nrwl/workspace/src/core/affected-project-graph/affected-project-graph.js:42:36
    at Array.forEach (<anonymous>)
    at addAffectedNodes (/.../node_modules/@nrwl/workspace/src/core/affected-project-graph/affected-project-graph.js:42:12)
    at /.../node_modules/@nrwl/workspace/src/core/affected-project-graph/affected-project-graph.js:42:36
    at Array.forEach (<anonymous>)
    at addAffectedNodes (/.../node_modules/@nrwl/workspace/src/core/affected-project-graph/affected-project-graph.js:42:12)
    at /.../node_modules/@nrwl/workspace/src/core/affected-project-graph/affected-project-graph.js:42:36
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This issue still happens in NX 10.3.0 version

8.11.1 was released and an upgrade resolved the CICD issues.

@raheelriax: interesting find: the same is valid for my case. I am seeing:

Invalid project name is detected: "@angular/http"

and indeed: master has that @angular/http as a dependency in package.json, whereas my branch removed that. I’m also on 8.11.0. I’m not really sure if I can be of help to solve this issue (will dig into code to see how it works), but can gladly help reproduce or verify the issue to help facilitate a fix!

I am also facing the same issue when I run affected:lint against my origin/develop. I did some digging and found out that’s because I’ve removed a dependency from my package.json and origin/develop still has it listed in his dependencies, this should not break the affected command. So the question is what should be the right action if someone has a dependency mismatch?

I am happy to work on this issue if someone can tell me what should be the expected action

I am using

@nrwl/angular : Not Found @nrwl/cli : 8.11.0 @nrwl/cypress : 8.11.0 @nrwl/eslint-plugin-nx : 8.11.0 @nrwl/express : 8.11.0 @nrwl/jest : 8.10.1 @nrwl/linter : 8.11.0 @nrwl/nest : Not Found @nrwl/next : Not Found @nrwl/node : 8.11.0 @nrwl/react : 8.11.0 @nrwl/schematics : Not Found @nrwl/tao : 8.11.0 @nrwl/web : 8.11.0 @nrwl/workspace : 8.11.0 typescript : 3.5.3

repo to reproduce - https://github.com/zaverden/nx-affected-error/tree/affected-error

  1. clone
  2. switch to affected-error branch
  3. run any affected command, for example yarn affected:apps

Steps:

  1. create ws
  2. add some dependency, for example moment
  3. commit to master
  4. start new branch
  5. remove the dependency
  6. drop dist folder (to remove nxdeps cache)
  7. run affected command

The source of a problem: getTouchedNpmPackages returns removed packages as touched, but createProjectGraph includes only actual nodes[type=‘npm’]