Repository navigation
fix(resolver): keep hoisted peer providers out of the root peer context - #12847
Conversation
|
💖 Thanks for opening this pull request! 💖 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR fixes a peer-dependency resolution bug where root-attached peer providers were being re-resolved in the root context, incorrectly binding self-contained subtree packages to the root's incompatible package version. It threads hoisted peer-provider node ids through pnpm11 and pacquet resolution paths, adds fixtures, and adds regression tests. ChangesHoisted Peer Provider Resolution Fix
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Installer
participant resolveDependencyTree
participant resolveDependencies
participant resolvePeers
participant Lockfile
Installer->>resolveDependencies: resolve root and subtree deps
resolveDependencies->>resolveDependencies: mark appended peer addresses as hoistedPeerProvider
resolveDependencies->>resolveDependencyTree: return pkgAddresses
resolveDependencyTree->>resolveDependencyTree: collect hoistedPeerProviderNodeIds
resolveDependencyTree->>resolvePeers: pass importers with hoistedPeerProviderNodeIds
resolvePeers->>resolvePeers: partition own vs hoisted-provider direct children
resolvePeers->>resolvePeers: resolve own children in main pass
resolvePeers->>resolvePeers: resolve pruned hoisted providers via root-context fallback
resolvePeers->>Lockfile: bind subtree peers to closure-provided versions
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
There was a problem hiding this comment.
Pull request overview
Fixes a peer-resolution bug with autoInstallPeers: true where peer providers that were hoisted/attached to the root importer for reuse were also being peer-resolved again in the root context, allowing an incompatible root dependency to “poison” a self-contained transitive closure’s peer graph. The change is implemented in both the TypeScript pnpm CLI resolver and the Rust pacquet/ resolver, and is covered by new fixtures and regression tests.
Changes:
- TypeScript: mark “hoisted peer providers” and skip traversing them as root children during the root-context peer walk, with a targeted fallback when their real tree position was pruned by the peers cache.
- Rust (pacquet): thread hoisted-provider node IDs through
ResolvePeersOptionsand apply the same “skip unless pruned” behavior in the peer walker. - Add minimal registry fixtures plus mirrored regression tests in both stacks, and a changeset for the published resolver package +
pnpm.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
pnpr/.fixtures/packages/@pnpm.e2e/closure-plugins/1.0.0/package.json |
Adds a minimal fixture package that represents a self-contained closure root. |
pnpr/.fixtures/packages/@pnpm.e2e/closure-peer-x/1.0.0/package.json |
Adds fixture for the “correct” peer version inside the closure. |
pnpr/.fixtures/packages/@pnpm.e2e/closure-peer-x/2.0.0/package.json |
Adds fixture for the incompatible root-level peer version used in the regression scenario. |
pnpr/.fixtures/packages/@pnpm.e2e/closure-lib-a/1.0.0/package.json |
Adds fixture library participating in mutual peer dependencies within the closure. |
pnpr/.fixtures/packages/@pnpm.e2e/closure-lib-b/1.0.0/package.json |
Adds fixture library participating in mutual peer dependencies within the closure. |
pnpm11/installing/deps-resolver/src/resolvePeers.ts |
Skips hoisted peer providers in the root traversal and adds a cache-prune fallback resolution path. |
pnpm11/installing/deps-resolver/src/resolveDependencyTree.ts |
Collects hoistedPeerProviderNodeIds per importer so the peer resolver can recognize hoisted providers. |
pnpm11/installing/deps-resolver/src/resolveDependencies.ts |
Flags hoisted peer-provider PkgAddress entries when they’re attached to the root importer for reuse. |
pnpm11/installing/deps-resolver/src/index.ts |
Threads hoistedPeerProviderNodeIds through project inputs to the peer-resolution passes. |
pnpm11/installing/deps-installer/test/install/autoInstallPeers.ts |
Adds a regression test asserting closure peers don’t bind to an incompatible root dependency. |
pacquet/crates/resolving-deps-resolver/src/tests.rs |
Updates test options construction to use defaults after adding a new options field. |
pacquet/crates/resolving-deps-resolver/src/resolve_workspace.rs |
Aggregates hoisted-provider node IDs from importers and passes them into workspace peer resolution. |
pacquet/crates/resolving-deps-resolver/src/resolve_peers.rs |
Implements “skip hoisted providers as root children unless pruned” in the Rust peer walker. |
pacquet/crates/resolving-deps-resolver/src/resolve_importer.rs |
Tracks and exports the hoisted-provider node IDs attached during auto-install-peers hoisting. |
pacquet/crates/package-manager/src/install/tests.rs |
Adds the mirrored Rust regression test asserting no poisoning of closure peers by the root. |
.changeset/peer-closures-root-context.md |
Publishes the fix as a patch changeset for @pnpm/installing.deps-resolver and pnpm. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12847 +/- ##
==========================================
- Coverage 85.35% 85.34% -0.01%
==========================================
Files 453 453
Lines 70868 71074 +206
==========================================
+ Hits 60488 60661 +173
- Misses 10380 10413 +33 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pnpm11/installing/deps-installer/test/install/autoInstallPeers.ts (1)
778-786: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider asserting root's own choice is preserved too.
Adding a check that the root importer's own
closure-peer-xbinding still resolves to2.0.0(e.g. vialockfile.importers['.'].dependencies) would confirm the fix doesn't accidentally suppress the root's explicit version choice while fixing the subtree, strengthening confidence in the regression coverage.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pnpm11/installing/deps-installer/test/install/autoInstallPeers.ts` around lines 778 - 786, The current test in autoInstallPeers only checks the closure subtree, but it should also verify the root importer keeps its explicit closure-peer-x version choice. Extend the assertions around project.readLockfile() and lockfile.importers['.'] to confirm the root dependency binding still resolves to 2.0.0 while the closure-lib snapshots remain free of that version, using the existing lockfile and pluginsSnapshot checks as the anchor.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pnpm11/installing/deps-installer/test/install/autoInstallPeers.ts`:
- Around line 778-786: The current test in autoInstallPeers only checks the
closure subtree, but it should also verify the root importer keeps its explicit
closure-peer-x version choice. Extend the assertions around
project.readLockfile() and lockfile.importers['.'] to confirm the root
dependency binding still resolves to 2.0.0 while the closure-lib snapshots
remain free of that version, using the existing lockfile and pluginsSnapshot
checks as the anchor.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 9e097a86-3db4-4ddd-b93f-67c70c50b9cd
📒 Files selected for processing (16)
.changeset/peer-closures-root-context.mdpacquet/crates/package-manager/src/install/tests.rspacquet/crates/resolving-deps-resolver/src/resolve_importer.rspacquet/crates/resolving-deps-resolver/src/resolve_peers.rspacquet/crates/resolving-deps-resolver/src/resolve_workspace.rspacquet/crates/resolving-deps-resolver/src/tests.rspnpm11/installing/deps-installer/test/install/autoInstallPeers.tspnpm11/installing/deps-resolver/src/index.tspnpm11/installing/deps-resolver/src/resolveDependencies.tspnpm11/installing/deps-resolver/src/resolveDependencyTree.tspnpm11/installing/deps-resolver/src/resolvePeers.tspnpr/.fixtures/packages/@pnpm.e2e/closure-lib-a/1.0.0/package.jsonpnpr/.fixtures/packages/@pnpm.e2e/closure-lib-b/1.0.0/package.jsonpnpr/.fixtures/packages/@pnpm.e2e/closure-peer-x/1.0.0/package.jsonpnpr/.fixtures/packages/@pnpm.e2e/closure-peer-x/2.0.0/package.jsonpnpr/.fixtures/packages/@pnpm.e2e/closure-plugins/1.0.0/package.json
|
Addressed both review points in 85eb9a9:
Written by an agent (Claude Code, claude-fable-5). |
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.1473925951399995,
"stddev": 0.32631338336930465,
"median": 4.05970961164,
"user": 3.50364948,
"system": 1.9662776000000002,
"min": 3.79428592764,
"max": 4.76879687564,
"times": [
4.76879687564,
3.92173931564,
4.16324862064,
3.95617060264,
4.39743698664,
4.31282191464,
3.90176479264,
3.79428592764,
4.45197777064,
3.8056831446399997
]
},
{
"command": "pacquet@main",
"mean": 4.39004037754,
"stddev": 0.4604065260533572,
"median": 4.37679846514,
"user": 3.4518422799999997,
"system": 1.9395692,
"min": 3.84858435264,
"max": 5.05363439364,
"times": [
4.97437212764,
4.37529764664,
4.1970784306399995,
4.91275387764,
3.87954945764,
5.05363439364,
4.40190211964,
4.37829928364,
3.87893208564,
3.84858435264
]
},
{
"command": "pnpr@HEAD",
"mean": 2.37367811204,
"stddev": 0.16167775271845192,
"median": 2.39343528764,
"user": 2.3364623799999995,
"system": 1.5782994,
"min": 2.17075138364,
"max": 2.57005029764,
"times": [
2.49283380264,
2.23152045364,
2.50119209164,
2.29403677264,
2.25076550364,
2.57005029764,
2.17075138364,
2.18021519264,
2.49485624164,
2.55055938064
]
},
{
"command": "pnpr@main",
"mean": 2.4459468638399997,
"stddev": 0.22725482184401752,
"median": 2.4246699221399997,
"user": 2.31545588,
"system": 1.6225341999999998,
"min": 2.04689768564,
"max": 2.79865289064,
"times": [
2.46902099064,
2.79865289064,
2.4339847896399998,
2.6653181026399997,
2.41535505464,
2.38809746364,
2.31201742064,
2.04689768564,
2.23116956164,
2.69895467864
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6995343802,
"stddev": 0.1699346978578369,
"median": 0.7019307425000001,
"user": 0.33211244,
"system": 0.6758831399999998,
"min": 0.545492675,
"max": 1.1196289700000002,
"times": [
0.710815928,
1.1196289700000002,
0.720408176,
0.580326168,
0.721467972,
0.555374754,
0.693045557,
0.545492675,
0.780100912,
0.5686826899999999
]
},
{
"command": "pacquet@main",
"mean": 0.7010048815,
"stddev": 0.1215031471367424,
"median": 0.7060116745,
"user": 0.33244413999999994,
"system": 0.69211324,
"min": 0.555745854,
"max": 0.913976859,
"times": [
0.662700476,
0.740599669,
0.555745854,
0.848505897,
0.573248803,
0.67142368,
0.743795563,
0.556771078,
0.743280936,
0.913976859
]
},
{
"command": "pnpr@HEAD",
"mean": 1.2263443606,
"stddev": 0.40942526936416956,
"median": 1.0979703340000002,
"user": 0.35306983999999997,
"system": 0.7138330399999998,
"min": 0.73360446,
"max": 2.024184336,
"times": [
1.285407001,
1.055046683,
0.73360446,
0.818761458,
0.948472937,
1.671063549,
1.556811807,
2.024184336,
1.1408939850000002,
1.02919739
]
},
{
"command": "pnpr@main",
"mean": 0.8752456439999998,
"stddev": 0.30023249797484397,
"median": 0.7869880335,
"user": 0.34035434,
"system": 0.68186484,
"min": 0.572615756,
"max": 1.651672658,
"times": [
0.766627009,
0.983929746,
0.774231872,
0.751061127,
0.884654047,
0.799744195,
1.651672658,
0.934195299,
0.633724731,
0.572615756
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.188354350799999,
"stddev": 0.2584168560386458,
"median": 4.074678799199999,
"user": 3.28137926,
"system": 1.8351941799999998,
"min": 3.9461073762,
"max": 4.7299223592,
"times": [
4.7299223592,
4.137075461199999,
4.073781084199999,
4.0755765142,
3.9461073762,
4.062077544199999,
4.012859210199999,
4.006794364199999,
4.2896135852,
4.549736009199999
]
},
{
"command": "pacquet@main",
"mean": 4.361624450999999,
"stddev": 0.270367899406952,
"median": 4.3429640362,
"user": 3.3267678600000004,
"system": 1.85267078,
"min": 4.081316397199999,
"max": 4.9613552701999994,
"times": [
4.2338588262,
4.3017376692,
4.0821919412,
4.9613552701999994,
4.4898129531999995,
4.1077360402,
4.081316397199999,
4.3841904032,
4.5533412671999995,
4.4207037422
]
},
{
"command": "pnpr@HEAD",
"mean": 2.8401677561999996,
"stddev": 0.56440913085692,
"median": 2.8667800996999997,
"user": 2.1302661600000006,
"system": 1.5367911799999998,
"min": 2.0716738732,
"max": 3.7160956412,
"times": [
3.5689822712,
3.7160956412,
2.9049802802,
2.2525882852,
2.8719777092,
3.3316242422,
2.3179627802,
2.0716738732,
2.5042099892,
2.8615824902
]
},
{
"command": "pnpr@main",
"mean": 2.4478584816,
"stddev": 0.36972893607675983,
"median": 2.3516714967,
"user": 2.15156526,
"system": 1.5462514799999998,
"min": 2.0592333082,
"max": 3.3342881042,
"times": [
2.7049938842,
2.2886469212000002,
3.3342881042,
2.2968197422,
2.1468857912,
2.5782462452,
2.4778360252000002,
2.1851115432,
2.4065232512,
2.0592333082
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.2486408528600001,
"stddev": 0.12433489589695074,
"median": 1.2127411600600002,
"user": 1.1547391,
"system": 0.90987036,
"min": 1.1482783835600001,
"max": 1.58589981756,
"times": [
1.23372272856,
1.2296272535600001,
1.1873514735600001,
1.19585506656,
1.1482783835600001,
1.27743234756,
1.18468141956,
1.19155833956,
1.58589981756,
1.25200169856
]
},
{
"command": "pacquet@main",
"mean": 1.21309091806,
"stddev": 0.07442697533378176,
"median": 1.17918497156,
"user": 1.1430656,
"system": 0.9183881599999999,
"min": 1.15680550456,
"max": 1.38588190856,
"times": [
1.25228104056,
1.15716916856,
1.18481137856,
1.16164410856,
1.38588190856,
1.2796940805600001,
1.17355856456,
1.16114929856,
1.15680550456,
1.21791412756
]
},
{
"command": "pnpr@HEAD",
"mean": 0.58562724876,
"stddev": 0.021089363568745696,
"median": 0.58368198056,
"user": 0.2932916,
"system": 0.6488904599999998,
"min": 0.5678997775600001,
"max": 0.63892037956,
"times": [
0.5856913675600001,
0.5905384705600001,
0.63892037956,
0.59528381856,
0.5823153815600001,
0.58504857956,
0.56970315656,
0.57195484456,
0.5678997775600001,
0.56891671156
]
},
{
"command": "pnpr@main",
"mean": 0.71818784566,
"stddev": 0.18675597499918967,
"median": 0.5995290310600001,
"user": 0.29910709999999996,
"system": 0.65721136,
"min": 0.5733650935600001,
"max": 1.08984754856,
"times": [
1.08984754856,
0.82837129756,
0.9675216635600001,
0.7579975655600001,
0.5959511005600001,
0.5734660355600001,
0.5733650935600001,
0.59630008956,
0.59994499556,
0.5991130665600001
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.7719904235799997,
"stddev": 0.10384553650259275,
"median": 2.73489988988,
"user": 1.5934499400000002,
"system": 1.0857152600000002,
"min": 2.68821879738,
"max": 3.03743310438,
"times": [
2.72143518838,
2.8355307283799998,
2.69789748738,
2.7904514953799997,
2.7483083813799998,
2.72149139838,
2.70842023238,
2.68821879738,
2.77071742238,
3.03743310438
]
},
{
"command": "pacquet@main",
"mean": 2.76980935518,
"stddev": 0.13382668850750218,
"median": 2.71641448138,
"user": 1.58027134,
"system": 1.0752591599999999,
"min": 2.66645610938,
"max": 3.08236767538,
"times": [
2.72875209638,
2.67386515438,
2.69785961338,
2.7874135073799997,
2.70407686638,
2.66645610938,
2.74049003338,
2.68950678738,
3.08236767538,
2.92730570838
]
},
{
"command": "pnpr@HEAD",
"mean": 0.5867393423800001,
"stddev": 0.021147208570332292,
"median": 0.58129012738,
"user": 0.29260014,
"system": 0.6482467599999999,
"min": 0.5706908013800001,
"max": 0.63833700638,
"times": [
0.5718519883800001,
0.58456918138,
0.5706908013800001,
0.58685261538,
0.5710899633800001,
0.58074600138,
0.58183425338,
0.57424597438,
0.60717563838,
0.63833700638
]
},
{
"command": "pnpr@main",
"mean": 0.6070401809800001,
"stddev": 0.04243891473810144,
"median": 0.59787939088,
"user": 0.2928960400000001,
"system": 0.66644446,
"min": 0.57228654038,
"max": 0.7208901443800001,
"times": [
0.7208901443800001,
0.6130805583800001,
0.59861260638,
0.60981823438,
0.58910973738,
0.57228654038,
0.5796462063800001,
0.57973366338,
0.59714617538,
0.61007794338
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.5538038535800001,
"stddev": 0.00788958008423962,
"median": 0.55099944148,
"user": 0.53371052,
"system": 0.09848979999999999,
"min": 0.54282558648,
"max": 0.5651378634800001,
"times": [
0.56117773248,
0.54949984148,
0.54628983548,
0.56183568948,
0.5651378634800001,
0.56167744048,
0.55173877248,
0.54759566348,
0.55026011048,
0.54282558648
]
},
{
"command": "pacquet@main",
"mean": 0.55067408748,
"stddev": 0.011353046987556379,
"median": 0.5493537149800001,
"user": 0.5361510199999999,
"system": 0.09424809999999999,
"min": 0.53760737848,
"max": 0.56654686448,
"times": [
0.56654686448,
0.56201315548,
0.56109278948,
0.56172404648,
0.53760737848,
0.55174175648,
0.53896381848,
0.54696567348,
0.54018432748,
0.53990106448
]
},
{
"command": "pnpr@HEAD",
"mean": 0.09413705298000001,
"stddev": 0.0021211802876510265,
"median": 0.09490272898000002,
"user": 0.023493753333333332,
"system": 0.010494599999999996,
"min": 0.08991499248000001,
"max": 0.09747496248000001,
"times": [
0.09295770748000001,
0.09423379848,
0.09133919848000001,
0.09052425648000001,
0.09747496248000001,
0.09431820648000001,
0.09648209248,
0.09522425748,
0.09373162548000001,
0.09517657048000001,
0.09135103748000001,
0.09595005248,
0.09505914048000001,
0.09491937948000001,
0.09075767548000001,
0.09116193648000001,
0.09672369648000001,
0.09436268748000001,
0.09609168448000001,
0.09510504148000001,
0.09554431248,
0.09590770448000001,
0.09530757848,
0.09539643948000001,
0.08991499248000001,
0.09093596048000001,
0.09488607848000001,
0.09233012948000001,
0.09466961548000001,
0.09627377048
]
},
{
"command": "pnpr@main",
"mean": 0.09409678864666667,
"stddev": 0.0022648003271246984,
"median": 0.09522484398,
"user": 0.02278505333333333,
"system": 0.010995000000000001,
"min": 0.08964305648000001,
"max": 0.09664054148000001,
"times": [
0.09278159648,
0.09534551048,
0.09461726848,
0.09072987548000001,
0.09083348748,
0.09071016948,
0.09044471348000001,
0.08964305648000001,
0.09145261748000001,
0.09573135048,
0.09551018048000001,
0.09664054148000001,
0.09485057048000001,
0.09603742548000001,
0.09584692848000001,
0.09625409848000001,
0.09522011348000001,
0.09546506048,
0.09495771148000001,
0.09526541148,
0.09512405848000001,
0.09635204948000001,
0.09619938848000001,
0.09563607848000001,
0.09382648848000001,
0.09527498348,
0.09522957448000001,
0.08991812648000001,
0.09134679548,
0.09565842848
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 9.36771167222,
"stddev": 1.6934955485425083,
"median": 9.47241098582,
"user": 3.461398199999999,
"system": 2.03497874,
"min": 7.049972257319999,
"max": 12.313761014319999,
"times": [
12.313761014319999,
10.63133213432,
8.72502102232,
8.02776206832,
7.712905495319999,
7.049972257319999,
10.21980094932,
10.54369035232,
10.46491980432,
7.98795162432
]
},
{
"command": "pacquet@main",
"mean": 7.744223406719999,
"stddev": 0.7785262117022373,
"median": 7.645787499819999,
"user": 3.4711092,
"system": 2.04451174,
"min": 6.804824743319999,
"max": 9.03314351232,
"times": [
8.15518848332,
7.806293216319999,
9.03314351232,
7.432235900319999,
6.804824743319999,
7.48528178332,
7.04703317432,
8.87730799132,
7.933244440319999,
6.86768082232
]
},
{
"command": "pnpr@HEAD",
"mean": 7.53039467832,
"stddev": 1.4188188320862667,
"median": 7.85567319682,
"user": 2.4179025999999997,
"system": 1.68714674,
"min": 5.53979244232,
"max": 9.31344081232,
"times": [
5.53979244232,
5.61835123132,
5.84940768032,
7.2608614843199994,
7.68982021932,
8.30747611632,
8.67906688732,
9.31344081232,
8.02152617432,
9.02420373532
]
},
{
"command": "pnpr@main",
"mean": 7.00684309202,
"stddev": 1.9170140146517745,
"median": 6.39329141382,
"user": 2.4232840999999996,
"system": 1.7246344399999998,
"min": 5.70498070032,
"max": 12.16750637432,
"times": [
12.16750637432,
7.37168293432,
6.5112928833199994,
6.10495678732,
6.27528994432,
5.85811712932,
5.70498070032,
7.59112534632,
5.93496426532,
6.54851455532
]
}
]
} |
|
| Branch | pr/12847 |
| Testbed | pnpr |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 2,204.82 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 695.11 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 726.00 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 112.01 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 2,194.71 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 4,918.19 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 724.33 ms |
With autoInstallPeers, peers resolved inside a dependency subtree are attached to the root importer's direct dependencies so other subtrees can reuse them. Those entries alias tree nodes that already have a position deep in the graph, and the peer-resolution pass walked them a second time as root children. The two walks raced on the shared per-node dep-path state, so a package inside a self-contained closure could get its peers bound to the root project's incompatible version of a peer instead of the provider next to it in the tree, producing a lockfile that mixes both versions and a peer mismatch at run time. The peer-resolution pass now keeps the attached providers visible as root-level peer providers but resolves their own peers only at their true tree position, falling back to the root context only when that position was pruned by the peers cache. The fix lands in both stacks: the TypeScript `@pnpm/installing.deps-resolver` and pacquet's `resolving-deps-resolver` crate. Fixes pnpm#4993 Signed-off-by: C. Spencer Beggs <[email protected]>
Address review feedback on the closure-poisoning fix: unit tests now exercise the root-context fallback for a hoisted peer provider whose tree position was pruned (both the single-importer walk and the workspace pass), and the regression tests in both stacks additionally assert that the root importer's own explicitly declared peer version is preserved while the subtree keeps its own. Signed-off-by: C. Spencer Beggs <[email protected]>
85eb9a9 to
51dd7f7
Compare
Code Review by Qodo
Context used✅ Compliance rules (platform):
51 rules 1. Rust test doc comment wrong
|
PR Code Suggestions ✨Latest suggestions up to 3241953 Warning
Previous suggestionsSuggestions up to commit ebf9261
Suggestions up to commit 0b3d834
Suggestions up to commit 3ccc80f
Suggestions up to commit 51dd7f7
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
Each resolvePeersOfChildren call only detects peer cycles among its own children. The root-context fallback resolved every pruned hoisted peer provider in its own call, so two pruned providers that peer-depend on each other (the usual shape of a self-contained closure) left their dep path calculations awaiting each other forever and the install hung. Resolving all still-pruned providers in one call restores the cycle short-circuit. Pacquet's sequential walker already handles this shape — build_peer_id falls back to a provisional name@version id and the SCC finalization pass corrects the suffixes — so it needs no code change and only gains the mirrored regression tests proving both stacks emit identical dep paths. The TS side also gains a unit test mirroring pacquet's single-pruned-provider fallback coverage. Co-Authored-By: Claude Fable 5 <[email protected]>
The identifiers liba and libb fail the repository spellcheck; the hyphenated names also match the closure-lib-a fixture naming the rest of the PR uses. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Code review by qodo was updated up to the latest commit 0b3d834 |
…ts manifest The pruned-provider rename commit accidentally carried a regenerated lockfile for this fixture that lists is-number, which the fixture's package.json does not declare. prepare-fixtures installs every fixture with a frozen lockfile, so all CI test jobs failed before running any tests. Co-Authored-By: Claude Fable 5 <[email protected]>
A local install over the fixtures workspace reformatted seven fixture lockfiles that are unrelated to this PR; restore them to their previous committed state. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Code review by qodo was updated up to the latest commit 3241953 |
When deduplicating a missing peer onto the workspace's preferred versions, hoistPeers matched candidates against '*' unless the wanted range was an exact version. In a multi-importer workspace, allPreferredVersions aggregates versions from every importer, so a peer declared as ^1.0.0 inside one importer's closure could be auto-installed as a 2.x resolved for another importer, silently producing a peer graph that mixes incompatible majors. This survived pnpm#12847 (which fixed the single-importer case in resolvePeers) and is independent of the pnpm#12921 deadlock fix: the wrong version is chosen upstream of peer resolution, during peer hoisting. Both stacks now dedupe onto the highest preferred version that satisfies the wanted range and fall back to resolving the range from the registry when no candidate satisfies it. Non-semver specifiers (workspace:, npm: aliases, dist-tags) keep the dedupe-to-highest behavior. Fixing this exposed a pacquet-only divergence the old behavior masked: resolve_peers indexed a node's children into ParentRefs only by their install alias, so an npm-alias child could never provide a peer under its real package name below the importer level, and the binding fell through to the importer-level hoisted entry. Descent-time children are now indexed by both alias and real name, matching resolvePeers.ts. Measured on the multi-importer reproduction: 46 poisoned snapshots on pnpm 11.11.0, 0 with this change, in both the TypeScript CLI and pacquet. Signed-off-by: C. Spencer Beggs <[email protected]>
When deduplicating a missing peer onto the workspace's preferred versions, hoistPeers matched candidates against '*' unless the wanted range was an exact version. In a multi-importer workspace, allPreferredVersions aggregates versions from every importer, so a peer declared as ^1.0.0 inside one importer's closure could be auto-installed as a 2.x resolved for another importer, silently producing a peer graph that mixes incompatible majors. This survived pnpm#12847 (which fixed the single-importer case in resolvePeers) and is independent of the pnpm#12921 deadlock fix: the wrong version is chosen upstream of peer resolution, during peer hoisting. Both stacks now dedupe onto the highest preferred version that satisfies the wanted range and fall back to resolving the range from the registry when no candidate satisfies it. Non-semver specifiers (workspace:, npm: aliases, dist-tags) keep the dedupe-to-highest behavior. Fixing this exposed a pacquet-only divergence the old behavior masked: resolve_peers indexed a node's children into ParentRefs only by their install alias, so an npm-alias child could never provide a peer under its real package name below the importer level, and the binding fell through to the importer-level hoisted entry. Descent-time children are now indexed by both alias and real name, matching resolvePeers.ts. Measured on the multi-importer reproduction: 46 poisoned snapshots on pnpm 11.11.0, 0 with this change, in both the TypeScript CLI and pacquet. Signed-off-by: C. Spencer Beggs <[email protected]>
…ge (#12932) When deduplicating a missing peer onto the workspace's preferred versions, hoistPeers matched candidates against '*' unless the wanted range was an exact version. In a multi-importer workspace, allPreferredVersions aggregates versions from every importer, so a peer declared as ^1.0.0 inside one importer's closure could be auto-installed as a 2.x resolved for another importer, silently producing a peer graph that mixes incompatible majors. This survived #12847 (which fixed the single-importer case in resolvePeers) and is independent of the #12921 deadlock fix: the wrong version is chosen upstream of peer resolution, during peer hoisting. Both stacks now dedupe onto the highest preferred version that satisfies the wanted range and fall back to resolving the range from the registry when no candidate satisfies it. Non-semver specifiers (workspace:, npm: aliases, dist-tags) keep the dedupe-to-highest behavior. Fixing this exposed a pacquet-only divergence the old behavior masked: resolve_peers indexed a node's children into ParentRefs only by their install alias, so an npm-alias child could never provide a peer under its real package name below the importer level, and the binding fell through to the importer-level hoisted entry. Descent-time children are now indexed by both alias and real name, matching resolvePeers.ts. Measured on the multi-importer reproduction: 46 poisoned snapshots on pnpm 11.11.0, 0 with this change, in both the TypeScript CLI and pacquet. Additionally, hoistPeers now binds the same peer on a re-resolve with an existing lockfile as on a fresh install of the same manifest: root dependencies reused from the lockfile skip full resolution and were invisible to the workspace-root branch of the hoist, so the picked version depended on whether a lockfile was present. The root-dep table falls back to the importer's wanted specifiers, and its entry type is narrowed to HoistableRootDep — the fields hoistPeers reads, matching the Rust port's WorkspaceRootDep. Related to #12847 and #12921. --------- Signed-off-by: C. Spencer Beggs <[email protected]> Co-authored-by: Zoltan Kochan <[email protected]>
Summary
With
autoInstallPeers: true, a package version present in a workspace project's own dependencies can leak into the peer resolution of packages deep inside a transitive dependency's closure, overriding the version that closure provides for itself — nearest-dependent resolution should win, and didn't. Fixes #4993 (related analysis in https://github.com/orgs/pnpm/discussions/6450).Concrete case: a project declares
effect@^4.0.0-beta.93(dev + peer) plus a bundler whose transitive dependency ships a fully self-contained Effect v3 closure ([email protected]and every@effect/*package as regular dependencies). The resolver bound theeffectpeer of some of those packages to the importer's4.0.0-beta.93, producing an incoherent snapshot that mixes([email protected])and([email protected])suffixes under one parent, and crashing at runtime withERR_MODULE_NOT_FOUNDwhen a v3-built package gets Effect v4 linked as its peer. A minimal public reproduction lives at spencerbeggs/pnpm-closure-minimal.Root cause. When
autoInstallPeersis enabled,resolveRootDependenciesattaches every peer that was resolved at an intermediate depth to the root importer'spkgAddressesso other subtrees can reuse it (introduced in #4855). Those attached entries alias tree nodes that already have a position deep in the graph, andresolvePeerswalked them a second time as root children. The two walks raced on the shared per-node dep-path state (pathsByNodeIdplus its single-shot promises), so each node's final peer binding depended on which context wrote last — hence only some siblings being poisoned. In pacquet the walker is sequential, so the root-context walk deterministically overwrote every in-place resolution and the whole closure was poisoned.Fix. The attached providers stay visible as root-level peer providers (other subtrees can still resolve their missing peers against them — the behavior the existing "hoist a peer dependency in order to reuse it" tests codify), but they are no longer peer-resolved in the root context. Their own peers now resolve only at their true tree position, with a fallback to the root context only when that position was pruned by the peers cache and nothing else resolved them. Same fix in both stacks: the pushed addresses are flagged (
PkgAddress.hoistedPeerProviderin TypeScript,ResolvePeersOptions::hoisted_peer_provider_node_idsin pacquet) and both peer walks skip flagged entries unless unresolved after the main traversal.Follow-up: fallback deadlock. The root-context fallback originally resolved each pruned provider in its own peer-resolution pass. A pass only detects peer cycles among its own children, and providers frequently peer-depend on each other (the closure fixture's two libs do exactly that), so two pruned providers would leave their dep path calculations awaiting each other forever and hang the install. The TypeScript fallback now resolves all still-pruned providers in a single pass, restoring the cycle short-circuit. Pacquet's sequential walker already self-heals here —
build_peer_idfalls back to a provisionalname@versionid and the SCC finalization pass corrects the suffixes — so it needed no code change. Mirrored unit tests in both stacks pin identical dep-path output for the pruned single-provider and mutual-peer-cycle scenarios.Verification. New registry fixtures (
@pnpm.e2e/closure-*) model the shape minimally: a self-contained closure whose two libs peer-depend on each other and on a shared peer, plus an incompatible root version of that peer. Matching tests in both stacks were confirmed to fail before the fix and pass after. On the real-world reproduction, all four cells of the isolation matrix (incompatible root version present/absent ×autoInstallPeerson/off) now resolve everyeffectpeer in the closure to3.21.4, withpnpm peers checkclean, in both the TypeScript CLI and pacquet.Squash Commit Body
Checklist
pacquet/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Written by an agent (Claude Code, claude-fable-5).
Signed-off-by: C. Spencer Beggs [email protected]
Summary by CodeRabbit