Nx: affected error (Maximum call stack size exceeded)

Created on 24 Oct 2019  Â·  21Comments  Â·  Source: nrwl/nx

After update to 8.7.0 i have error. On 8.6.0 all right.

Expected Behavior

Show correct affected projects

Current Behavior

I have error, and nothing else.

Failure Information (for bugs)

RangeError: Maximum call stack size exceeded

Steps to Reproduce

run nx affected:apps or nx affected:libs

Context

Nx 8.7.0

Failure Logs

C:\Projects\Angular\terrasoft>nx affected:apps
C:\Projects\Angular\node_modules\@nrwl\workspace\node_modules\yargs\yargs.js:1109
else throw err
^

RangeError: Maximum call stack size exceeded
at C:\Projects\Angular\node_modules\@nrwl\workspace\src\command-line\affected.js:119:70
at Array.forEach ()
at _visit (C:\Projects\Angular\node_modules\@nrwl\workspace\src\command-line\affected.js:119:62)
at C:\Projects\Angular\node_modules\@nrwl\workspace\src\command-line\affected.js:120:4
at Array.forEach ()
at _visit (C:\Projects\Angular\node_modules\@nrwl\workspace\src\command-line\affected.js:119:62)
at C:\Projects\Angular\node_modules\@nrwl\workspace\src\command-line\affected.js:120:4
at Array.forEach ()
at _visit (C:\Projects\Angular\node_modules\@nrwl\workspace\src\command-line\affected.js:119:62)
at C:\Projects\Angular\node_modules\@nrwl\workspace\src\command-line\affected.js:120:4

repro needed retry with latest bug

Most helpful comment

after update on 8.10.1 i have error again

All 21 comments

Yep, happens to me as well :+1:

Could someone please provide a repo with the issue to aid our investigation into this issue.

I have the same issue and I believe it might have something to do with cyclic dependencies but I'm not 100% sure. ):

I can't provide a repro, not yet at least, but I wonder if sharing my dep graph would help?
dep-graph.json.zip

Happened to me as well

For me it was a circular dependency.

I just ran npm run lint, found out what the circular dependency was, fixed it, and everything is fine again 🎉

It's supposed to support circular dependencies, otherwise it should be mentioned in the docs.

@marcus-sa done: #2028

@trumbitta isn't this a regression? Because all commands used to support circular dependencies.

This is definitely a regression. As I mentioned, we can't update to this version now ):

@marcus-sa yep I think it is, but I think a simple heads up in the docs could qualify as an improvement while they find the time to actually fix the issue

I see the same problem as well in a very strange way. Unfortunately, I can't provide a repo to reproduce. Following the hints here, I fixed some real cyclic dependencies in our repo.

Finally, I could run affected:libs --all successfully and I commited my changes. Now, strange things happened:
I merged another branch into mine. After this, the error occurred again. I checked out the commit above, the error was still there. I made irrelevant changes to angular.json, the error was gone. I reverted the irrelevant changes and had a clean git status again. The error was still gone. Just as if something in the file system which is not seen by git status is involved in this bug.
This happens on Ubuntu 19.04.

A perhaps related observation:

Some cyclic dependency warnings were still displayed but I think that they are erroneous:
We have (besides other apps and libs) in angular.json an app

"print": {
            "root": "apps/print/",
...
}

and two libs

"print-shared": {
            "root": "libs/print/shared",
...
},
"contract-print": {
            "root": "libs/print/contract-print",
...
}

I ensured that print-shared does not have any references to print and contract-print.
Contract-print references print-shared, but does not have any references to print
One of the (incorrect) cyclic dependency warnings is a cycle between "print" and "print". Is the logic for evaluating the dependencies between libs/apps perhaps thrown off track because the libs share a common directory libs/print?

I browsed through the nx code over the weekend and I found that the dependencies are cached in dist/nxdeps.json. This might explain the strange behaviour I saw on friday.

And I found out how to reproduce the error in my case. When I fixed the circular dependencies, I introduced a new lib called print-shared. In tsconfig.json, I had two path mappings:

"@destimo/print/contract-print": ["libs/print/contract-print/src"],
"@destimo/print/print-shared": ["libs/print/shared/src"],

When I change these mappings (remove the subpath in the path alias) to

"@destimo/contract-print": ["libs/print/contract-print/src"],
"@destimo/print-shared": ["libs/print/shared/src"],

affected:libs works. I can provided the nxdeps.json for both cases, if needed.

Are path aliases like "project/module/submodule" supported by Typescript?

I browsed through the nx code over the weekend and I found that the dependencies are cached in dist/nxdeps.json. This might explain the strange behaviour I saw on friday.

And I found out how to reproduce the error in my case. When I fixed the circular dependencies, I introduced a new lib called print-shared. In tsconfig.json, I had two path mappings:

"@destimo/print/contract-print": ["libs/print/contract-print/src"],
"@destimo/print/print-shared": ["libs/print/shared/src"],

When I change these mappings (remove the subpath in the path alias) to

"@destimo/contract-print": ["libs/print/contract-print/src"],
"@destimo/print-shared": ["libs/print/shared/src"],

affected:libs works. I can provided the nxdeps.json for both cases, if needed.

Are path aliases like "project/module/submodule" supported by Typescript?

deleting the nxdeps.json solved it for me!

Folks,

  • There was an issue with circular dependencies in 8.7.0, but it has been fixed. Could you try it with latest?
  • If it is still present, could you provide a repro?

@vsavkin We upgraded to 8.9.0 and issues seem to be resolved

My issues are resolved as well after upgrading to 8.9.0 and downgrading my code to before cleaning up the cyclic dependencies

It all works fine for us as well, thank you @vsavkin

Closing as this is resolved with the latest version :).

This is now valid again after updating to nx 8.10.1 ):

```› yarn affected:lint
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 ()
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 ()
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 ()
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.
```

after update on 8.10.1 i have error again

Tested different versions and the regression appears in 8.10.0, 8.9.0 is ok.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SWGeekPD picture SWGeekPD  Â·  3Comments

joelmuskwe picture joelmuskwe  Â·  3Comments

danieldanielecki picture danieldanielecki  Â·  3Comments

ZempTime picture ZempTime  Â·  3Comments

sukei picture sukei  Â·  3Comments