Repository navigation
fix(engine): reuse the pinned pnpm when nodeVersion names another major - #16498
Conversation
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? |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Repository: pnpm/pnpm/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: pnpm/pnpm/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe engine configuration now clears the project’s ChangesPinned pnpm reuse
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Assessment against linked issues
Suggested labels
Merge Risk: ⚪ Minimal · up to The change aligns pinned pnpm installation and reuse across differing project Node.js versions. No actionable merge-blocking issue remains; merge after normal checks pass. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change is narrow and preserves the existing package-selection, verification and locking paths. No introduced security defect was established. Residual uncertainty concerns protection of cached executables and behavior during interrupted or concurrent installation. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The fix alters a subtle shared engine-install/caching path with an intentional side effect on engineStrict checking and offline reinstall behavior, which the author notes is unverified on Linux and Windows, so final human review is warranted.
Review effort: Balanced
Findings: None
What changed in this PR
This PR fixes a pnpm v12 (pacquet) bug where a project that pins pnpm and sets nodeVersion to a Node.js major different from the node on PATH would reinstall the pinned pnpm on every switching command, failing offline. The engine's global-virtual-store (GVS) slot is keyed on the host's Node.js major by compute_engine_slot (via detect_node_major), but the install was run with the project's config still carrying nodeVersion, so the slot was written under the project's major and never found on lookup. The fix drops node_version from the engine install config so the install, env-lockfile resolution, and slot lookup all key on the host.
Changes:
package_manager_engine_confignow setsconfig.node_version = None, with a doc comment explaining why.- Added an e2e regression test that installs a pinned engine with a mismatched
nodeVersion, then verifies a second--versionreuses it against an unreachable registry. - Added a
pacquetpatch changeset describing the user-visible fix.
| File | Description |
|---|---|
pnpm/crates/cli/src/engine_pm/install.rs |
Drops node_version from the engine config so the GVS slot keys on the host Node major, with an explanatory doc comment. |
pnpm/crates/cli/tests/suite/version.rs |
Adds a regression test proving the pinned engine is reused offline when nodeVersion names another major. |
.changeset/engine-slot-ignores-node-version.md |
Release note for the fix, targeting pacquet with a patch bump. |
I verified that package_manager_engine_config is the config used for both sync_engine_dependencies (env resolution) and the install, that detect_installability_host consumes config.node_version to build the install host and engine name, and that compute_engine_slot independently uses detect_node_major() — so dropping node_version aligns the written slot with the looked-up slot. The test's node-major selection always differs from the host, dbg!(&output) matches the surrounding test convention, and the changeset follows the repo's style rules. No defects found.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16498 +/- ##
==========================================
- Coverage 92.22% 92.22% -0.01%
==========================================
Files 1530 1530
Lines 205782 205845 +63
==========================================
+ Hits 189776 189831 +55
- Misses 16006 16014 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Same-run regression checkHEAD and main are measured on the same runner. The tolerance is 5% of the main median or 2 ms, whichever is larger. A regression requires both the median slowdown and the gap between the fastest retained HEAD sample and slowest retained main sample to exceed this tolerance, after trimming up to 10% from each tail. Suspected regressions are rerun once with target order reversed and only fail if reproduced. This conservative noise guard is not a statistical confidence interval. Inconclusive rows do not fail the check. They remain visible for performance review. Bencher retains absolute minimum timings for historical tracking; historical alerts do not gate this PR. Sequential measurements can still be affected by runner drift.
Integrated-Benchmark Report (Linux)Commit: Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm; the linked-workspace scenario compares current Rust against main Rust. Bencher consumes pacquet@HEAD and pnpr@HEAD. The tables below show mean ± σ. Bencher tracks absolute minimum latency; PR regression checks compare HEAD and main samples from the same runner. Historical timing alerts do not gate PRs. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.79815495678,
"stddev": 0.15148366098999191,
"median": 2.77727374368,
"user": 2.7068622799999997,
"system": 2.44360802,
"min": 2.63274649468,
"max": 3.0283566606799996
},
{
"command": "pacquet@main",
"mean": 2.6747480797799996,
"stddev": 0.1404303784760316,
"median": 2.66105036068,
"user": 2.5996447799999998,
"system": 2.31571962,
"min": 2.50148165268,
"max": 2.95869738268
},
{
"command": "pnpr@HEAD",
"mean": 1.58818357548,
"stddev": 0.11916944741342418,
"median": 1.60613639568,
"user": 2.1105140799999997,
"system": 1.8276230199999997,
"min": 1.40365412668,
"max": 1.7755838266800001
},
{
"command": "pnpr@main",
"mean": 1.64016909728,
"stddev": 0.15347009958426616,
"median": 1.64718501518,
"user": 2.32463658,
"system": 2.09966922,
"min": 1.40492729568,
"max": 1.92867527468
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.5674305730800001,
"stddev": 0.12642300249282223,
"median": 0.5543686589800001,
"user": 0.5856177600000001,
"system": 0.93234862,
"min": 0.41445989398000005,
"max": 0.8186610299800001
},
{
"command": "pacquet@main",
"mean": 0.5286041595800001,
"stddev": 0.07969800386907469,
"median": 0.50119363248,
"user": 0.5845627600000001,
"system": 0.9530259200000002,
"min": 0.44876415098000005,
"max": 0.7141408489800001
},
{
"command": "pnpr@HEAD",
"mean": 0.4558692860800001,
"stddev": 0.0643003829234546,
"median": 0.44590415098,
"user": 0.51567326,
"system": 0.9020774199999998,
"min": 0.35891899998000004,
"max": 0.55856519098
},
{
"command": "pnpr@main",
"mean": 0.39597202068000004,
"stddev": 0.04485200483504724,
"median": 0.38399906048,
"user": 0.42508086,
"system": 0.80373542,
"min": 0.33985041998000004,
"max": 0.46241630198000006
}
]
}Scenario: Isolated linker: repeat install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.011419663643636358,
"stddev": 0.0012521950222404753,
"median": 0.0112692512,
"user": 0.006387110909090912,
"system": 0.006284754181818184,
"min": 0.0091432292,
"max": 0.017177998200000003
},
{
"command": "pacquet@main",
"mean": 0.011807928430125524,
"stddev": 0.0015805955589759102,
"median": 0.0118347352,
"user": 0.006766591380753136,
"system": 0.0063343314644351495,
"min": 0.0082818452,
"max": 0.0160551212
},
{
"command": "pnpr@HEAD",
"mean": 0.011648668498507464,
"stddev": 0.0013492527931115998,
"median": 0.011300122700000002,
"user": 0.006687477910447757,
"system": 0.006294796343283578,
"min": 0.0095141332,
"max": 0.0165605442
},
{
"command": "pnpr@main",
"mean": 0.012172244553658545,
"stddev": 0.001062244251021597,
"median": 0.0119566557,
"user": 0.006881738861788615,
"system": 0.006730466829268292,
"min": 0.0099622452,
"max": 0.015528098200000002
}
]
}Scenario: Isolated linker: repeat install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.015457066278079103,
"stddev": 0.0016705171142656272,
"median": 0.015298117860000002,
"user": 0.008525900677966105,
"system": 0.00865500700564972,
"min": 0.012473556860000002,
"max": 0.022866837860000003
},
{
"command": "pacquet@main",
"mean": 0.016481503475942027,
"stddev": 0.002124728639294499,
"median": 0.01657363086,
"user": 0.009395931014492752,
"system": 0.00887549405797102,
"min": 0.01098897086,
"max": 0.021987030860000003
},
{
"command": "pnpr@HEAD",
"mean": 0.014538288327105254,
"stddev": 0.0015560901235626271,
"median": 0.01473720086,
"user": 0.008203210000000002,
"system": 0.007875196052631577,
"min": 0.010919130860000001,
"max": 0.018281340860000002
},
{
"command": "pnpr@main",
"mean": 0.014894441458901108,
"stddev": 0.0014655816935197393,
"median": 0.01502548486,
"user": 0.007980965494505499,
"system": 0.008588244505494506,
"min": 0.01121252986,
"max": 0.018521669860000003
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.7431346238600005,
"stddev": 0.17498346787741167,
"median": 2.69562492366,
"user": 2.6595513799999995,
"system": 2.0126493799999996,
"min": 2.58649440766,
"max": 3.18940555966
},
{
"command": "pacquet@main",
"mean": 2.88849500326,
"stddev": 0.12204461980272667,
"median": 2.8782765351600004,
"user": 3.01476988,
"system": 2.23505238,
"min": 2.74277188166,
"max": 3.08144911766
},
{
"command": "pnpr@HEAD",
"mean": 1.66221056796,
"stddev": 0.12247257238564974,
"median": 1.6306802416600001,
"user": 1.6824261799999998,
"system": 1.7788168800000002,
"min": 1.5106461096600001,
"max": 1.92598194766
},
{
"command": "pnpr@main",
"mean": 1.81389685386,
"stddev": 0.24605141473456496,
"median": 1.8470350251600003,
"user": 1.9728026799999996,
"system": 2.0944504800000003,
"min": 1.46474869166,
"max": 2.25661841366
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.50607107676,
"stddev": 0.026711642548117566,
"median": 0.50742443866,
"user": 0.7024881199999999,
"system": 0.8043008599999999,
"min": 0.46389023416,
"max": 0.5605940741600001
},
{
"command": "pacquet@main",
"mean": 0.62063156756,
"stddev": 0.022140950340819494,
"median": 0.61192228066,
"user": 0.90980322,
"system": 1.01046206,
"min": 0.59075646016,
"max": 0.6593418441600001
},
{
"command": "pnpr@HEAD",
"mean": 0.39354697756000007,
"stddev": 0.009015998569946457,
"median": 0.39593954366000006,
"user": 0.39073522,
"system": 0.7933226600000001,
"min": 0.38194523116,
"max": 0.40791552016000004
},
{
"command": "pnpr@main",
"mean": 0.39454534066,
"stddev": 0.015315582297461335,
"median": 0.39413639766,
"user": 0.40221202,
"system": 0.77525836,
"min": 0.36502566416000004,
"max": 0.42302914916
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.9667824412800001,
"stddev": 0.07968655685480713,
"median": 1.94858356438,
"user": 1.55057318,
"system": 1.30585964,
"min": 1.8909913568799999,
"max": 2.16088346488
},
{
"command": "pacquet@main",
"mean": 2.0086308813800002,
"stddev": 0.11114219361722344,
"median": 1.97150577238,
"user": 1.62177558,
"system": 1.38539264,
"min": 1.8711412198800002,
"max": 2.24073263988
},
{
"command": "pnpr@HEAD",
"mean": 0.47239108798,
"stddev": 0.02850878181766855,
"median": 0.46618098138,
"user": 0.4666230799999999,
"system": 0.91531294,
"min": 0.43533175788,
"max": 0.5429620328800001
},
{
"command": "pnpr@main",
"mean": 0.5023421055800001,
"stddev": 0.019345263008154458,
"median": 0.5018964018800001,
"user": 0.45746057999999995,
"system": 0.92605254,
"min": 0.47218406588,
"max": 0.5356373098800001
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.36030357162000004,
"stddev": 0.10640169507546267,
"median": 0.32040701202000005,
"user": 0.36900521999999997,
"system": 0.14561828,
"min": 0.24746417352,
"max": 0.54526535052
},
{
"command": "pacquet@main",
"mean": 0.30917755672,
"stddev": 0.04313954365328481,
"median": 0.32208221402000003,
"user": 0.31206332,
"system": 0.12036398000000001,
"min": 0.23879932352000002,
"max": 0.36742949452000007
},
{
"command": "pnpr@HEAD",
"mean": 0.10246032001999998,
"stddev": 0.005462330200455249,
"median": 0.10157589152,
"user": 0.04094367000000001,
"system": 0.019018113333333333,
"min": 0.09539909452,
"max": 0.11840459252
},
{
"command": "pnpr@main",
"mean": 0.10453038319857143,
"stddev": 0.005329121977209972,
"median": 0.10412287702,
"user": 0.04395499142857142,
"system": 0.019409065714285714,
"min": 0.09642855252,
"max": 0.12228909552
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.3572467095333334,
"stddev": 0.04691362957973227,
"median": 0.36244339820000004,
"user": 0.38788167111111116,
"system": 0.08707797777777776,
"min": 0.29024210320000005,
"max": 0.41936898320000005
},
{
"command": "pacquet@main",
"mean": 0.3321589838666667,
"stddev": 0.03362525488037986,
"median": 0.3308308682,
"user": 0.35620056,
"system": 0.0847142,
"min": 0.28184768320000003,
"max": 0.38344395220000005
},
{
"command": "pnpm@HEAD",
"mean": 4.857369576755556,
"stddev": 0.26316303819803893,
"median": 4.845940973199999,
"user": 7.836504448888888,
"system": 0.4793285333333334,
"min": 4.3335810552,
"max": 5.1909896261999995
}
]
}Scenario: Isolated linker: linked-workspace resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.2604732379566667,
"stddev": 0.02511145610650719,
"median": 0.25190715604,
"user": 0.22005104333333333,
"system": 0.09253949333333333,
"min": 0.22971335654,
"max": 0.30317341954000004
},
{
"command": "pacquet@main",
"mean": 0.26095831920666673,
"stddev": 0.03445084306932893,
"median": 0.25614632004000004,
"user": 0.20471562666666665,
"system": 0.10856232666666665,
"min": 0.22604107254,
"max": 0.35892967354000005
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 5.405675195480001,
"stddev": 0.31728894934525875,
"median": 5.30707885288,
"user": 2.8529035800000004,
"system": 2.60175622,
"min": 5.04325287038,
"max": 6.00973866638
},
{
"command": "pacquet@main",
"mean": 6.06202295338,
"stddev": 0.21389510444810056,
"median": 6.04739936388,
"user": 2.92197748,
"system": 2.8093885199999997,
"min": 5.68039889538,
"max": 6.407240231379999
},
{
"command": "pnpr@HEAD",
"mean": 5.1387955214800005,
"stddev": 0.33666390172673133,
"median": 5.187305418379999,
"user": 2.8367591799999996,
"system": 2.7618547199999997,
"min": 4.54341021838,
"max": 5.54708724538
},
{
"command": "pnpr@main",
"mean": 5.3963940182800005,
"stddev": 0.40978088649273064,
"median": 5.28763662088,
"user": 2.9515025799999997,
"system": 2.8660619200000004,
"min": 4.75087222838,
"max": 6.12015414638
}
]
}Scenario: GVS linker: fresh restore, hot cache + hot storeSame install as the isolated fresh-restore hot/hot scenario, into the shared virtual store, the layout pnpm 12 installs into by default. Scenarios run on separate machines, so compare main and branch within each table.
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.27746792754000005,
"stddev": 0.03800018530407247,
"median": 0.28090018454000004,
"user": 0.32132143,
"system": 0.22170400666666668,
"min": 0.20952183154,
"max": 0.35184345154
},
{
"command": "pacquet@main",
"mean": 0.29545178226727276,
"stddev": 0.03726508171957265,
"median": 0.28443168954000003,
"user": 0.34866263454545454,
"system": 0.21934256727272727,
"min": 0.23966294154,
"max": 0.35993873854
},
{
"command": "pnpr@HEAD",
"mean": 0.33125860554000003,
"stddev": 0.05327655682844533,
"median": 0.33103977254000005,
"user": 0.35294758000000004,
"system": 0.23350793999999997,
"min": 0.25991034654000006,
"max": 0.40709310654
},
{
"command": "pnpr@main",
"mean": 0.3386688614400001,
"stddev": 0.03281641550456063,
"median": 0.3293244525400001,
"user": 0.37995528,
"system": 0.21879774,
"min": 0.29986011654000005,
"max": 0.39966200354000003
}
]
} |
The engine install ran with the project's config, including its `nodeVersion`, so the global-virtual-store slot was hashed with that Node.js major. The cache lookup keys the slot on the `node` on PATH. When the two majors differ, the lookup never finds the installed engine, and every command that switches to the pinned pnpm reinstalls it through the registry, which also fails offline. Drop `nodeVersion` from the engine config. The engine runs on the host's Node.js, the env lockfile is already resolved against it, and the TypeScript CLI's engine install never reads the setting. Closes #16497
3683189 to
4ba2968
Compare
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can keep summaries lean with Findings visible per group, which tucks the rest behind a View link |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The fix is correct and well-tested, but it changes engineStrict/engine-install slot-keying semantics in a subtle way the author flagged as unverified on Linux and Windows, warranting final human review.
Review effort: Balanced
Findings: None
|
Reviewed, rebased onto main, and followed through CI.
Nothing remains within scope. Written by an agent (Claude Code, claude-opus-5-5). |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Code review by qodo was updated up to the latest commit 5115ffa |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Although the one-line fix is well-reasoned and tested, it changes behavior in the sensitive engine-bootstrap path with subtle downstream effects (engineStrict now checks the host node, and the engine env lockfile resolves against the host rather than nodeVersion), which warrants human judgment.
Review effort: Balanced
Findings: None
Summary
Closes #16497
The bug
A project pins pnpm 12.8.1 and sets
nodeVersion: 22.13.0inpnpm-workspace.yaml. The machine runs Node.js 24. Every pnpm command in that project downloads pnpm 12.8.1 again, although it was already downloaded. Each command takes about a second instead of about 0.1 s, and with no network every command fails.The bug needs both a pinned pnpm and a
nodeVersionwhose major differs from thenodeonPATH. It has been there since 12.0.0. pnpm v11 is not affected.Why it happened
pnpm keeps downloaded pnpm versions in a shared store. A version's directory name includes the Node.js major it was installed for. pnpm v12 used two different majors for that name:
nodeonPATH(24).nodeVersion(22) applied.The version was stored under the
node22name and looked up under thenode24name, so the lookup never found it.The fix
The install of pnpm itself now ignores the project's
nodeVersion(package_manager_engine_configinpnpm/crates/cli/src/engine_pm/install.rs). The downloaded pnpm runs on thenodeonPATH, not onnodeVersion, so the install and the lookup now use the same major. Projects without the mismatch get the same directory as before.nodeVersionstill applies to the project's own dependencies. This change affects only how pnpm installs itself.One more effect: with
engineStrict: true, pnpm's ownengines.nodeis now checked against thenodeonPATH, not againstnodeVersion. That is the Node.js pnpm actually runs on.Test
version_flag_reuses_the_pinned_engine_when_node_version_names_another_majorrunspnpm --versiontwice in a project with a pinned pnpm and a mismatchednodeVersion. The second run uses an unreachable registry. Without the fix the second run fails withERR_PNPM_RESOLVING_NPM_RESOLVER_NETWORK_ERROR. With the fix it passes.Measurements
pnpm --versionin the example project, macOS arm64, mean of 5 runs:Squash Commit Body
Checklist
already linked to it solves it.
are implemented in every affected version.
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, Opus 5.5).
Summary by CodeRabbit