Skip to content
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

failed to show cycle dependencies info #5059

Closed
jerrychen4git opened this issue Jul 19, 2022 · 1 comment · Fixed by pnpm/graph-sequencer#2
Closed

failed to show cycle dependencies info #5059

jerrychen4git opened this issue Jul 19, 2022 · 1 comment · Fixed by pnpm/graph-sequencer#2

Comments

@jerrychen4git
Copy link

pnpm version:

7.5.0

Code to reproduce the issue:

in attatchment cycletest.zip
dependencies a->b->c->d->b

Expected behavior:

show cyclic workspace dependency detail about b to b cycle

Actual behavior:

only show "WARN  There are cyclic workspace dependencies " but no detail about cycle

Additional information:

getCycles function use cached visited map to skip recursive call of visit, but check cycle by compare cycle[0] === dep .
if check cycle first from a , package b to d will be added to visited map , but no cycle is found , then check from b, recursive call of visit function will be skipped at c .

function getCycles(currDepsMap, visited) {
let items = Array.from(currDepsMap.keys());
let cycles = [];
function visit(item, cycle) {
let visitedDeps = visited.get(item);
if (!visitedDeps) {
visitedDeps = [];
visited.set(item, visitedDeps);
}
let deps = currDepsMap.get(item);
if (typeof deps === "undefined")
return;
for (let dep of deps) {
if (cycle[0] === dep) {
cycles.push(cycle);
}
if (!visitedDeps.includes(dep)) {
visitedDeps.push(dep);
visit(dep, cycle.concat(dep));
}
}
}
for (let item of items) {
visit(item, [item]);
}
return cycles;
}

  • node -v prints: v16.15.0

  • Windows, macOS, or Linux?: Windows

@gajus
Copy link

gajus commented Apr 11, 2023

@zkochan just flagging that this is a valid bug that was buried

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants