Skip to content

Commit 868c04e

Browse files
authored
fix(core): moves the recursion check after deduplication (#3825)
* Fixes stack overflow check * Versions
1 parent 0ce9264 commit 868c04e

File tree

2 files changed

+42
-8
lines changed

2 files changed

+42
-8
lines changed

.yarn/versions/0d3ff95b.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
releases:
2+
"@yarnpkg/cli": patch
3+
"@yarnpkg/core": patch
4+
5+
declined:
6+
- "@yarnpkg/plugin-compat"
7+
- "@yarnpkg/plugin-constraints"
8+
- "@yarnpkg/plugin-dlx"
9+
- "@yarnpkg/plugin-essentials"
10+
- "@yarnpkg/plugin-exec"
11+
- "@yarnpkg/plugin-file"
12+
- "@yarnpkg/plugin-git"
13+
- "@yarnpkg/plugin-github"
14+
- "@yarnpkg/plugin-http"
15+
- "@yarnpkg/plugin-init"
16+
- "@yarnpkg/plugin-interactive-tools"
17+
- "@yarnpkg/plugin-link"
18+
- "@yarnpkg/plugin-nm"
19+
- "@yarnpkg/plugin-npm"
20+
- "@yarnpkg/plugin-npm-cli"
21+
- "@yarnpkg/plugin-pack"
22+
- "@yarnpkg/plugin-patch"
23+
- "@yarnpkg/plugin-pnp"
24+
- "@yarnpkg/plugin-pnpm"
25+
- "@yarnpkg/plugin-stage"
26+
- "@yarnpkg/plugin-typescript"
27+
- "@yarnpkg/plugin-version"
28+
- "@yarnpkg/plugin-workspace-tools"
29+
- "@yarnpkg/builder"
30+
- "@yarnpkg/doctor"
31+
- "@yarnpkg/nm"
32+
- "@yarnpkg/pnpify"
33+
- "@yarnpkg/sdks"

packages/yarnpkg-core/sources/Project.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,14 +2036,6 @@ function applyVirtualResolutionMutations({
20362036
continue;
20372037
}
20382038

2039-
// The stack overflow is checked against two level because a workspace
2040-
// may have a dev dependency on another workspace that lists the first
2041-
// one as a regular dependency. In this case the loop will break so we
2042-
// don't need to throw an exception.
2043-
const stackDepth = virtualStack.get(pkg.locatorHash);
2044-
if (typeof stackDepth === `number` && stackDepth >= 2)
2045-
reportStackOverflow();
2046-
20472039
let virtualizedDescriptor: Descriptor;
20482040
let virtualizedPackage: Package;
20492041

@@ -2122,6 +2114,15 @@ function applyVirtualResolutionMutations({
21222114
if (!allPackages.has(virtualizedPackage.locatorHash))
21232115
return;
21242116

2117+
// The stack overflow is checked against two level because a workspace
2118+
// may have a dev dependency on another workspace that lists the first
2119+
// one as a regular dependency. In this case the loop will break so we
2120+
// don't need to throw an exception.
2121+
const stackDepth = virtualStack.get(pkg.locatorHash);
2122+
2123+
if (typeof stackDepth === `number` && stackDepth >= 2)
2124+
reportStackOverflow();
2125+
21252126
const current = virtualStack.get(pkg.locatorHash);
21262127
const next = typeof current !== `undefined` ? current + 1 : 1;
21272128

0 commit comments

Comments
 (0)