Repository navigation
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthrough
ChangesGVS symlink conflict fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Suggested reviewers
✨ 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 |
PR Summary by QodoFix hoist: replace stale non-GVS symlinks when enabling global virtual store Description
Diagram
High-Level Assessment
Files changed (2)
|
There was a problem hiding this comment.
Pull request overview
Fixes hoisted dependency symlink replacement when switching a project from the legacy per-project virtual store (node_modules/.pnpm) to the global virtual store (storeDir/links), ensuring stale hoisted links are recognized as pnpm-internal and overwritten instead of being treated as “external” and skipped.
Changes:
- Extend
symlinkHoistedDependency()to treat symlinks targeting the project’s internal.pnpmdirectory as pnpm-internal (in addition to the activevirtualStoreDir) so they can be replaced during mode switches. - Add an end-to-end regression test covering the non-GVS → GVS transition and verifying that stale hoisted symlinks are updated.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
pnpm/test/install/globalVirtualStore.ts |
Adds a regression test ensuring stale hoisted symlinks are replaced when toggling GVS on. |
installing/linking/hoist/src/index.ts |
Updates hoist symlink replacement logic to also treat targets under the internal .pnpm dir as pnpm-internal. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code Review by Qodo
1. Racey unlink can fail install
|
|
Code review by qodo was updated up to the latest commit e522299 |
|
Code review by qodo was updated up to the latest commit 1c327d2 |
|
Code review by qodo was updated up to the latest commit 4f05bf0 |
|
Code review by qodo was updated up to the latest commit d94e00c |
|
A test failed. |
|
Code review by qodo was updated up to the latest commit cbe1a17 |
|
I fixed it. |
zkochan
left a comment
There was a problem hiding this comment.
No need for changes in pacquet? If this is not an issue in pacquet at the moment, at least a test should be added.
1 similar comment
|
Code review by qodo was updated up to the latest commit 247e628 |
|
Code review by qodo was updated up to the latest commit 03076c4 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12494 +/- ##
==========================================
- Coverage 88.15% 88.14% -0.01%
==========================================
Files 314 314
Lines 43514 43552 +38
==========================================
+ Hits 38360 38390 +30
- Misses 5154 5162 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Integrated-Benchmark Report (Linux)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": 3.8048435882600002,
"stddev": 0.14946373494057497,
"median": 3.7705487677600003,
"user": 3.63489288,
"system": 3.4216334,
"min": 3.61094028726,
"max": 4.073740422259999,
"times": [
3.96221087626,
3.78010929026,
3.76098824526,
3.89594228126,
3.67696087326,
3.89399218626,
3.75959835526,
3.63395306526,
4.073740422259999,
3.61094028726
]
},
{
"command": "pacquet@main",
"mean": 3.8273328780599996,
"stddev": 0.17168023528405282,
"median": 3.76085583426,
"user": 3.5742584799999997,
"system": 3.457702200000001,
"min": 3.62688685626,
"max": 4.045746405259999,
"times": [
4.045746405259999,
3.68933342926,
3.7774503412600002,
3.99085986526,
4.02445255426,
3.62688685626,
3.6781090082600003,
4.02163985126,
3.67458914226,
3.74426132726
]
},
{
"command": "pnpr@HEAD",
"mean": 2.09360401446,
"stddev": 0.14282731986074923,
"median": 2.03115847526,
"user": 2.64738348,
"system": 2.995445,
"min": 1.96734428026,
"max": 2.34889326426,
"times": [
1.96734428026,
2.05090361826,
2.15294578626,
2.34453517826,
2.01141333226,
1.99690869926,
2.05914853126,
1.99538745926,
2.34889326426,
2.00855999526
]
},
{
"command": "pnpr@main",
"mean": 2.0510560147600003,
"stddev": 0.10321818778938684,
"median": 2.0040448712599996,
"user": 2.63984798,
"system": 2.9858929000000005,
"min": 1.9384249372600002,
"max": 2.2497088182600002,
"times": [
2.16658176626,
2.15933929226,
2.2497088182600002,
1.9599179902600001,
1.9937652482600001,
2.00345859926,
2.0312737532600003,
2.00356179926,
2.00452794326,
1.9384249372600002
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6506516566,
"stddev": 0.012415805342675895,
"median": 0.6462760169,
"user": 0.3823714,
"system": 1.3294539799999998,
"min": 0.6336408389,
"max": 0.6686085049,
"times": [
0.6686085049,
0.6429382419,
0.6437911099,
0.6336408389,
0.6399812679,
0.6673628149,
0.6411356059000001,
0.6609716569,
0.6487609239000001,
0.6593256009
]
},
{
"command": "pacquet@main",
"mean": 0.6403462223,
"stddev": 0.017586985592273115,
"median": 0.6328828574,
"user": 0.3755092,
"system": 1.32430138,
"min": 0.6254468429000001,
"max": 0.6800960529000001,
"times": [
0.6274127129,
0.6361336989,
0.6266770349,
0.6296320159000001,
0.6439633169000001,
0.6280675959,
0.6254468429000001,
0.6507695439000001,
0.6552634079,
0.6800960529000001
]
},
{
"command": "pnpr@HEAD",
"mean": 0.6795283753,
"stddev": 0.014387170508805398,
"median": 0.6798715659000001,
"user": 0.3716487,
"system": 1.3599263799999997,
"min": 0.6611071279,
"max": 0.7025966319,
"times": [
0.7025966319,
0.6908764619000001,
0.6886964879,
0.6611071279,
0.6624061369,
0.6774580399000001,
0.6822850919000001,
0.6665610139,
0.6938220769000001,
0.6694746839000001
]
},
{
"command": "pnpr@main",
"mean": 0.6969372255999999,
"stddev": 0.0268234143787486,
"median": 0.6918519729,
"user": 0.37961100000000003,
"system": 1.3602281800000002,
"min": 0.6673169759,
"max": 0.7452706129000001,
"times": [
0.7452706129000001,
0.6884920869000001,
0.7412627629,
0.6713316269,
0.6926607199,
0.7008525209,
0.6745364049,
0.6966053189,
0.6673169759,
0.6910432259
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.23472601438,
"stddev": 0.034186957636405564,
"median": 4.230406481279999,
"user": 3.71761798,
"system": 3.42858254,
"min": 4.19622834728,
"max": 4.28759646328,
"times": [
4.19622834728,
4.20627592228,
4.28749984428,
4.28759646328,
4.25106519228,
4.25146293028,
4.23428660128,
4.19871794728,
4.20760053428,
4.2265263612799995
]
},
{
"command": "pacquet@main",
"mean": 4.215408580179999,
"stddev": 0.01764722119193976,
"median": 4.2177409057799995,
"user": 3.7254428799999992,
"system": 3.41312844,
"min": 4.17709427328,
"max": 4.242404307279999,
"times": [
4.242404307279999,
4.21777703428,
4.17709427328,
4.20555384228,
4.2020611062799995,
4.215741192279999,
4.228142076279999,
4.21770477728,
4.22091342428,
4.22669376828
]
},
{
"command": "pnpr@HEAD",
"mean": 2.17351509028,
"stddev": 0.068825262446067,
"median": 2.1627061317800003,
"user": 2.4969174799999996,
"system": 2.95065664,
"min": 2.0889950062800002,
"max": 2.28723905428,
"times": [
2.17585112228,
2.11265666228,
2.11177684328,
2.20664721828,
2.28723905428,
2.11561472628,
2.14956114128,
2.0889950062800002,
2.25439526128,
2.23241386728
]
},
{
"command": "pnpr@main",
"mean": 2.1487877745799997,
"stddev": 0.12200385211356525,
"median": 2.15719257628,
"user": 2.48598068,
"system": 2.9392431399999994,
"min": 2.00207387928,
"max": 2.4255191532800002,
"times": [
2.18234540928,
2.00207387928,
2.1744582012800002,
2.04730783928,
2.03534298328,
2.4255191532800002,
2.1995585492800003,
2.0769607422800003,
2.13992695128,
2.20438403728
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.32785765538,
"stddev": 0.011995776128541222,
"median": 1.3258456931799998,
"user": 1.3188119400000002,
"system": 1.7122707599999998,
"min": 1.31121005518,
"max": 1.34908398118,
"times": [
1.32111917718,
1.3368380631799999,
1.31577058118,
1.32948359018,
1.33753120818,
1.3222077961799998,
1.31852765618,
1.3368044451799999,
1.31121005518,
1.34908398118
]
},
{
"command": "pacquet@main",
"mean": 1.3315111940799997,
"stddev": 0.016000406848398263,
"median": 1.32933255018,
"user": 1.3195590400000001,
"system": 1.7188579599999998,
"min": 1.31212824218,
"max": 1.36608166118,
"times": [
1.32386604518,
1.33199572818,
1.31332996618,
1.31212824218,
1.36608166118,
1.33128190018,
1.32738320018,
1.34467039318,
1.3234441451799999,
1.3409306591799999
]
},
{
"command": "pnpr@HEAD",
"mean": 0.6882106820800001,
"stddev": 0.01824899524559501,
"median": 0.6840439546800001,
"user": 0.33855783999999994,
"system": 1.32897356,
"min": 0.6676414851800001,
"max": 0.7360353311800001,
"times": [
0.6876551301800001,
0.6774733901800001,
0.6676414851800001,
0.6804572361800001,
0.7360353311800001,
0.6819995511800001,
0.6860883581800001,
0.68151260018,
0.6915496741800001,
0.6916940641800001
]
},
{
"command": "pnpr@main",
"mean": 0.6562619570800001,
"stddev": 0.008687508738210203,
"median": 0.65732256718,
"user": 0.33994744,
"system": 1.28691026,
"min": 0.6428585101800001,
"max": 0.6702508971800001,
"times": [
0.6492069291800001,
0.6428585101800001,
0.6594107131800001,
0.65136269418,
0.6468338451800001,
0.6636537051800001,
0.6643508491800001,
0.6552344211800001,
0.65945700618,
0.6702508971800001
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.98549648322,
"stddev": 0.02763222251549822,
"median": 2.98307358802,
"user": 1.7591933400000002,
"system": 1.9589936799999996,
"min": 2.9457607175200002,
"max": 3.02825196752,
"times": [
3.02017816252,
2.97563883452,
2.97019687552,
2.9617281755200002,
2.9604113895200004,
2.9457607175200002,
3.01167485852,
2.99050834152,
2.9906155095200004,
3.02825196752
]
},
{
"command": "pacquet@main",
"mean": 2.9994341431200007,
"stddev": 0.05072498035707557,
"median": 2.9861358420200004,
"user": 1.75618524,
"system": 1.9555640799999996,
"min": 2.9668526345200004,
"max": 3.13957028552,
"times": [
2.99500911952,
2.9687502715200003,
2.9668526345200004,
2.9859329265200003,
2.96999332852,
3.00294139852,
2.98376280552,
2.99518990352,
3.13957028552,
2.9863387575200004
]
},
{
"command": "pnpr@HEAD",
"mean": 0.6879988524200001,
"stddev": 0.008870881711665578,
"median": 0.6876842900200001,
"user": 0.34125754,
"system": 1.32685978,
"min": 0.6726936835200001,
"max": 0.7028562325200001,
"times": [
0.6867186045200001,
0.6795207275200001,
0.6884141865200001,
0.6891208495200001,
0.6869543935200001,
0.6939465345200001,
0.7028562325200001,
0.6980895245200001,
0.6816737875200001,
0.6726936835200001
]
},
{
"command": "pnpr@main",
"mean": 0.6565159750200001,
"stddev": 0.011539370568852462,
"median": 0.6558947990200001,
"user": 0.33867314,
"system": 1.2819822799999998,
"min": 0.6458067685200001,
"max": 0.6867153115200001,
"times": [
0.6503388485200001,
0.6559812205200001,
0.6867153115200001,
0.6602863365200001,
0.6458067685200001,
0.6561346575200001,
0.6558083775200001,
0.6475577585200001,
0.6503465205200001,
0.6561839505200001
]
}
]
} |
|
| Branch | pr/12494 |
| Testbed | pacquet |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result milliseconds (ms) (Result Δ%) | Upper Boundary milliseconds (ms) (Limit %) |
|---|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot 🚷 view threshold | 4,234.73 ms(+0.21%)Baseline: 4,225.94 ms | 5,071.13 ms (83.51%) |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot 🚷 view threshold | 2,985.50 ms(-0.38%)Baseline: 2,997.02 ms | 3,596.42 ms (83.01%) |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot 🚷 view threshold | 1,327.86 ms(+0.12%)Baseline: 1,326.30 ms | 1,591.57 ms (83.43%) |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot 🚷 view threshold | 3,804.84 ms(-8.15%)Baseline: 4,142.28 ms | 4,970.74 ms (76.54%) |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot 🚷 view threshold | 650.65 ms(+5.04%)Baseline: 619.43 ms | 743.31 ms (87.53%) |
|
| Branch | pr/12494 |
| 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,173.52 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 688.00 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 688.21 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 2,093.60 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 679.53 ms |
…-store is toggled on
|
Code review by qodo was updated up to the latest commit 473255d |
1 similar comment
|
Code review by qodo was updated up to the latest commit 473255d |
…arget update_stale_hoist_symlink removed and recreated the symlink even when it already pointed at dep_dir, adding avoidable unlink + recreate I/O (and a transient missing-link window) on warm reinstalls. Add an already-correct fast path mirroring pacquet_fs::force_symlink_dir's existing_symlink_up_to_date. Also add the changeset the original fix was missing.
1 similar comment
| </content> | ||
| </invoke> |
There was a problem hiding this comment.
1. Malformed changeset content 🐞 Bug ⚙ Maintainability
The new changeset includes stray </content> and </invoke> lines, which are not part of the repository’s standard Changesets markdown format and will end up in the rendered changeset/release notes output. This should be removed to keep release notes clean and avoid tooling surprises.
Agent Prompt
## Issue description
A new Changesets entry contains two stray XML-like closing tags (`</content>`, `</invoke>`). These are not used anywhere else in this repo’s `.changeset/*.md` files and will be treated as literal markdown content.
## Issue Context
Changesets files in this repo follow: YAML frontmatter, blank line, then plain markdown body.
## Fix Focus Areas
- .changeset/gvs-replace-stale-hoisted-symlinks.md[1-8]
## Suggested fix
Delete the two trailing lines:
- `</content>`
- `</invoke>`
Leave the rest of the changeset text intact.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit 95b0dfe |
| pacquet_fs::remove_symlink_dir(dest).map_err(|error| { | ||
| crate::SymlinkPackageError::SymlinkDir { | ||
| symlink_target: dep_dir.to_path_buf(), | ||
| symlink_path: dest.to_path_buf(), | ||
| error, | ||
| } | ||
| })?; | ||
| pacquet_fs::symlink_dir(dep_dir, dest).map_err(|error| crate::SymlinkPackageError::SymlinkDir { | ||
| symlink_target: dep_dir.to_path_buf(), | ||
| symlink_path: dest.to_path_buf(), | ||
| error, | ||
| }) |
There was a problem hiding this comment.
1. Racey unlink can fail install 🐞 Bug ☼ Reliability
In pacquet, update_stale_hoist_symlink treats failures from remove_symlink_dir() / re-symlink_dir() as fatal; if another process removes dest between the readlink and unlink, the hoist pass can fail with NotFound instead of recovering. This is inconsistent with pacquet’s own force_symlink_dir logic, which explicitly ignores NotFound during unlink to tolerate concurrent mutations.
Agent Prompt
### Issue description
`update_stale_hoist_symlink()` unconditionally propagates errors from `remove_symlink_dir(dest)` and `symlink_dir(dep_dir, dest)`. If `dest` is concurrently removed (or replaced) after the `read_symlink_dir(dest)` check, the install may fail instead of gracefully treating the link as already gone and continuing.
### Issue Context
Pacquet already implements a race-tolerant unlink + retry pattern in `pacquet_fs::force_symlink_dir` (it ignores `NotFound` during unlink).
### Fix Focus Areas
- pacquet/crates/package-manager/src/hoist.rs[598-632]
- pacquet/crates/fs/src/symlink_dir.rs[198-209]
### Notes / Implementation guidance
- When `remove_symlink_dir(dest)` returns `NotFound`, treat it as a no-op (same as `force_symlink_dir`).
- Consider retrying `symlink_dir(dep_dir, dest)` if it returns `AlreadyExists` after removal (another process recreated it), by re-reading the link and re-evaluating whether it is stale/internal.
- Keep the conservative behavior for non-symlink occupants (leave as-is).
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| if pacquet_fs::lexical_normalize(&existing) == pacquet_fs::lexical_normalize(dep_dir) { | ||
| return Ok(()); | ||
| } | ||
| if !pacquet_fs::is_subdir(package_store_dir, &existing) | ||
| && !pacquet_fs::is_subdir(internal_pnpm_dir, &existing) | ||
| { |
There was a problem hiding this comment.
2. Extra path normalization overhead 🐞 Bug ➹ Performance
update_stale_hoist_symlink normalizes paths multiple times per existing hoist link (equality check plus two is_subdir calls, and is_subdir normalizes both inputs), adding avoidable CPU/alloc work on warm installs where most symlink_dir calls hit AlreadyExists. This can become noticeable in large hoisted graphs because the new introspection runs for every pre-existing hoist destination.
Agent Prompt
### Issue description
`update_stale_hoist_symlink()` performs repeated lexical normalization for the same paths:
- It normalizes `existing` and `dep_dir` for equality.
- It then calls `is_subdir()` twice, which normalizes its arguments again.
On warm installs (common case), `symlink_dir()` returns `AlreadyExists` for most hoisted destinations, so this extra per-link work is executed at scale.
### Issue Context
`pacquet_fs::is_subdir()` is filesystem-free but allocates `PathBuf`s via `lexical_normalize()` for both arguments.
### Fix Focus Areas
- pacquet/crates/package-manager/src/hoist.rs[541-632]
- pacquet/crates/fs/src/is_subdir.rs[14-18]
### Notes / Implementation guidance
- Normalize `existing` once (e.g., `existing_norm`) and normalize `dep_dir` once (`dep_norm`).
- For the subdir checks, either:
- normalize `package_store_dir` / `internal_pnpm_dir` once per `symlink_hoisted_dependencies` call and pass the normalized forms down, or
- add a small helper that does the prefix check against already-normalized values to avoid re-normalizing `existing` twice.
- Keep the current semantics (lexical, filesystem-free).
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit 809ec04 |
|
Code review by qodo was updated up to the latest commit 31bd0fc |
Summary
When
enable-global-virtual-storeis toggled on for a project that was previously installed without GVS,symlinkHoistedDependencysilently skips replacing existing hoisted symlinks atnode_modules/.pnpm/node_modules/<dep>. TheisSubdir(virtualStoreDir, existingSymlink)check compares againststoreDir/links(the GVS location), but stale symlinks from a prior non-GVS install point intonode_modules/.pnpm/— a path that is NOT a subdir ofstoreDir/links. The symlink is classified as "external" and left untouched, causing TypeScript to follow stale paths that may be incomplete or inconsistent.This aligns with the existing dual-check pattern already used by
safeIsInnerLinkininstalling/deps-resolver/src/safeIsInnerLink.ts:24-26.Scope: This fixes the stale-symlink transition bug. The broader TypeScript type inference issue (#9739) is also related to the GVS architectural limitation described in #12437 — packages executing from the links store can't resolve transitive deps because Node's
node_moduleswalk-up fromstoreDir/links/<hash>/node_modules/<pkg>/never reaches the project'snode_modules/. That requires a separate architectural fix.Related: #12437, #9618, #9696
Squash Commit Body
Checklist
pacquet/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any published package. Keep it short and written for pnpm users — it becomes a release note.Summary by CodeRabbit
Bug Fixes
Tests
package.jsonfiles appear in bothnode_modulesand the versioned Global Virtual Store links directory.