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
nx affected infinite loop #2367
Comments
I forgot to mention, but this stopped working on any version after
|
@alfaproject could you give it a try with 8.11.2? We rewrote how we compute the graph to make extensible, and missed a few things. Sorry about it. |
@vsavkin yes, I've tried every version and all of them fail one way or another. This issue was reported using 8.11.2 as you can see in the description |
@vsavkin I have just tried 8.12.0 and I have the same issue ): |
@vsavkin this patch fixes this regression: diff --git a/node_modules/@nrwl/workspace/src/core/affected-project-graph/affected-project-graph.js b/node_modules/@nrwl/workspace/src/core/affected-project-graph/affected-project-graph.js
index 11bab98..e3a2939 100644
--- a/node_modules/@nrwl/workspace/src/core/affected-project-graph/affected-project-graph.js
+++ b/node_modules/@nrwl/workspace/src/core/affected-project-graph/affected-project-graph.js
@@ -45,20 +45,19 @@ function addAffectedNodes(startingProject, reversed, builder, visited) {
if (!reversed.nodes[startingProject]) {
throw new Error(`Invalid project name is detected: "${startingProject}"`);
}
+ visited.push(startingProject);
builder.addNode(reversed.nodes[startingProject]);
const ds = reversed.dependencies[startingProject];
if (ds) {
- ds.forEach(({ target }) => addAffectedNodes(target, reversed, builder, [...visited, startingProject]));
+ ds.forEach(({ target }) => addAffectedNodes(target, reversed, builder, visited));
}
}
function addAffectedDependencies(startingProject, reversed, builder, visited) {
if (visited.indexOf(startingProject) > -1)
return;
+ visited.push(startingProject);
if (reversed.dependencies[startingProject]) {
- reversed.dependencies[startingProject].forEach(({ target }) => addAffectedDependencies(target, reversed, builder, [
- ...visited,
- startingProject
- ]));
+ reversed.dependencies[startingProject].forEach(({ target }) => addAffectedDependencies(target, reversed, builder, visited));
reversed.dependencies[startingProject].forEach(({ type, source, target }) => {
// Since source and target was reversed,
// we need to reverse it back to original direction. |
@vsavkin I don't mind making the above PR if you can verify that it's the correct solution |
@alfaproject @intellix It looks correct, and basically makes the visited array shared state. If you can open a PR we can take a look. Thanks! |
I’m in Egypt for the next 10 days and didn’t bring my laptop ): |
I will be providing a PR for this today so we can have a fix in the next release. FWIW, there wasn't an infinite loop but because we are creating a lot of new arrays + gc, the process became very CPU intensive. |
- Uses a shared mutable state between project traversals so we don't create new objects unnecessarily - Closes nrwl#2367
Thank you @jaysoo, much appreciated (: |
- Uses a shared mutable state between project traversals so we don't create new objects unnecessarily - Closes #2367
- Uses a shared mutable state between project traversals so we don't create new objects unnecessarily - Closes #2367
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. |
Expected Behavior
nx affected
command family completesCurrent Behavior
nx affected
command family does not complete (seems to go into an infinite loop)Failure Information (for bugs)
There really isn't more that I can say. The affected commands just don't finish unless I use
--all
.Steps to Reproduce
nx affected:lint
I can not share the project, but I'm ok to share the project graph:
project-graph.json.zip
I can also share any other metadata files like
nx.json
if it helps.Context
The text was updated successfully, but these errors were encountered: