Repository navigation
fix(pacquet): tolerate an already-removed cache mirror in metadata-fetch race tests - #13130
Ayush442842q wants to merge 2 commits into
Conversation
|
💖 Thanks for opening this pull request! 💖 |
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? |
|
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 selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe cache-race tests replace direct mirror deletion with a shared tolerant helper. Missing files are ignored, while other deletion failures still panic, allowing repeated mock requests to be reported by mock expectations. ChangesCache-race test cleanup
Estimated code review effort: 1 (Trivial) | ~5 minutes Assessment against linked issues
Possibly related PRs
Suggested labels: 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 |
Confidence Score: 5/5The change is test-only, minimal, and uses the correct idiomatic Rust error-kind matching without a TOCTOU window. It does not touch any production logic. The helper correctly matches directly on the io::ErrorKind already in hand — no secondary filesystem call, no race window. The four call sites are updated consistently, and the mock's .expect(1) / assert_async() contract is untouched, so the regression-detection capability is preserved. No files require special attention. Reviews (2): Last reviewed commit: "test(resolving-npm-resolver): check Erro..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@pnpm/crates/resolving-npm-resolver/src/fetch_full_metadata_cached/tests.rs`:
- Around line 425-429: Update remove_raced_mirror_tolerant to ignore deletion
failures only when the original std::fs::remove_file error has
ErrorKind::NotFound. Remove the path.exists() condition, and keep panicking with
the existing error message for every other error kind.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: ecbc59d6-6678-41b1-adbc-2db5adc2e95d
📒 Files selected for processing (1)
pnpm/crates/resolving-npm-resolver/src/fetch_full_metadata_cached/tests.rs
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13130 +/- ##
==========================================
+ Coverage 85.33% 85.65% +0.32%
==========================================
Files 505 505
Lines 81225 83565 +2340
==========================================
+ Hits 69315 71580 +2265
- Misses 11910 11985 +75 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
… removing raced mirror
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time). Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.51830081992,
"stddev": 0.15563449339797603,
"median": 2.5013032976200003,
"user": 1.52375602,
"system": 1.2832305000000002,
"min": 2.34611423812,
"max": 2.75969438612,
"times": [
2.64976539512,
2.75969438612,
2.39615047712,
2.57270633812,
2.7275630361200003,
2.54039211112,
2.36438621412,
2.34611423812,
2.4622144841200004,
2.36402151912
]
},
{
"command": "pacquet@main",
"mean": 2.5034752116200005,
"stddev": 0.18513618392394482,
"median": 2.4186773821200003,
"user": 1.4809799199999998,
"system": 1.2943474,
"min": 2.3382340701200004,
"max": 2.79639680612,
"times": [
2.43630844312,
2.3668917191200003,
2.3435447331200003,
2.77524554412,
2.3382340701200004,
2.40104632112,
2.79639680612,
2.52663098812,
2.69957344212,
2.35088004912
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5982448862200003,
"stddev": 0.13894819730492847,
"median": 1.63231351312,
"user": 1.0642994199999998,
"system": 1.1017886000000001,
"min": 1.42098178712,
"max": 1.7773974021199999,
"times": [
1.70096700812,
1.42098178712,
1.62405442712,
1.69618895912,
1.75541888412,
1.4300798641199999,
1.44679215212,
1.48999577912,
1.7773974021199999,
1.64057259912
]
},
{
"command": "pnpr@main",
"mean": 1.51639913562,
"stddev": 0.16822562524107937,
"median": 1.49270839312,
"user": 1.04917812,
"system": 1.1394078999999997,
"min": 1.34001091012,
"max": 1.8170684961199999,
"times": [
1.34001091012,
1.8170684961199999,
1.5585285971199998,
1.53338685912,
1.34220973012,
1.40953519112,
1.78456154612,
1.3932732401199999,
1.46857350712,
1.51684327912
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.25726546364,
"stddev": 0.00625743773571962,
"median": 0.25837084564000007,
"user": 0.20135012,
"system": 0.5493049400000001,
"min": 0.24848785414000002,
"max": 0.26693316614000007,
"times": [
0.26104153114000006,
0.26693316614000007,
0.24848785414000002,
0.26172183914,
0.25034334914000006,
0.26316242414,
0.25660078114000007,
0.25083818014000003,
0.25338460114000005,
0.26014091014000007
]
},
{
"command": "pacquet@main",
"mean": 0.25358711144,
"stddev": 0.004460055130797203,
"median": 0.25355074814000006,
"user": 0.20570511999999996,
"system": 0.53870274,
"min": 0.24811154814000003,
"max": 0.26054077114,
"times": [
0.25662371414000007,
0.25462701414000005,
0.25000480414000004,
0.25247448214000007,
0.24811154814000003,
0.26054077114,
0.25063419614000004,
0.25479394714000003,
0.25976405214000003,
0.24829658514000003
]
},
{
"command": "pnpr@HEAD",
"mean": 0.27030878474000003,
"stddev": 0.0033287830787659795,
"median": 0.26978563064000005,
"user": 0.22215832,
"system": 0.53413184,
"min": 0.26505073514000005,
"max": 0.27679535214000006,
"times": [
0.27093390014,
0.27195513714,
0.26761160414000007,
0.26505073514000005,
0.26981154914000005,
0.27679535214000006,
0.26916641614000003,
0.27390124214000006,
0.26810219914000005,
0.26975971214000005
]
},
{
"command": "pnpr@main",
"mean": 0.25730291494000007,
"stddev": 0.008884477780426673,
"median": 0.25766174564,
"user": 0.18904131999999998,
"system": 0.52613724,
"min": 0.24458365914000002,
"max": 0.27556164014000006,
"times": [
0.24803928814,
0.25111958714000004,
0.25329076914000004,
0.27556164014000006,
0.24458365914000002,
0.25604396614,
0.26126013014000005,
0.25955726314000005,
0.26429332114000004,
0.25927952514
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.6958864002199996,
"stddev": 0.013247407590249657,
"median": 2.6935587013199997,
"user": 1.6275630599999995,
"system": 1.2544947800000001,
"min": 2.6731345003199998,
"max": 2.71414698732,
"times": [
2.68247011332,
2.71071047532,
2.6932896343199997,
2.69853651632,
2.6880513373199997,
2.71145027532,
2.69382776832,
2.71414698732,
2.69324639432,
2.6731345003199998
]
},
{
"command": "pacquet@main",
"mean": 2.70203898002,
"stddev": 0.024943714471177172,
"median": 2.70186059432,
"user": 1.61181636,
"system": 1.27393138,
"min": 2.6568213583199998,
"max": 2.7453489323199998,
"times": [
2.70302194632,
2.70069924232,
2.69265340832,
2.6568213583199998,
2.7043553493199997,
2.7123785583199997,
2.6813430343199998,
2.69121974332,
2.7453489323199998,
2.73254822732
]
},
{
"command": "pnpr@HEAD",
"mean": 1.59676917312,
"stddev": 0.17915515763000678,
"median": 1.5432832588200003,
"user": 1.00541566,
"system": 1.13714098,
"min": 1.38837954832,
"max": 1.8260354493200002,
"times": [
1.38837954832,
1.8260354493200002,
1.81007360932,
1.5364516863200002,
1.7239366523200002,
1.40525790832,
1.5176767263200002,
1.80777531532,
1.5501148313200002,
1.4019900043200002
]
},
{
"command": "pnpr@main",
"mean": 1.5642673665200002,
"stddev": 0.17196010238520737,
"median": 1.5006901158200001,
"user": 0.9863325599999999,
"system": 1.13312438,
"min": 1.3921076003200001,
"max": 1.7994097933200002,
"times": [
1.7994097933200002,
1.3973595923200002,
1.7991270123200003,
1.4844254143200002,
1.40003888232,
1.6649801313200001,
1.51695481732,
1.3921076003200001,
1.4349610293200001,
1.75330939232
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.5504992400000002,
"stddev": 0.011413730272498942,
"median": 0.5489210905,
"user": 0.67680136,
"system": 0.6710590999999999,
"min": 0.5288601770000001,
"max": 0.5646138330000001,
"times": [
0.546437939,
0.5288601770000001,
0.5429718720000001,
0.56034022,
0.559485415,
0.5447052990000001,
0.551404242,
0.5646138330000001,
0.5632468690000001,
0.5429265340000001
]
},
{
"command": "pacquet@main",
"mean": 0.5440418175,
"stddev": 0.01192032360532279,
"median": 0.5414323470000001,
"user": 0.67391926,
"system": 0.6233690000000001,
"min": 0.531340428,
"max": 0.5654376770000001,
"times": [
0.5654376770000001,
0.5338025450000001,
0.5438151200000001,
0.5529714000000001,
0.5552478590000001,
0.5328767890000001,
0.533000671,
0.5528761120000001,
0.5390495740000001,
0.531340428
]
},
{
"command": "pnpr@HEAD",
"mean": 0.29920402030000004,
"stddev": 0.0068199957778497175,
"median": 0.2990018375,
"user": 0.18944816,
"system": 0.5272523,
"min": 0.29106116200000004,
"max": 0.30876663400000004,
"times": [
0.302575293,
0.291377765,
0.29320771700000003,
0.304870366,
0.302505743,
0.29443893600000004,
0.307738655,
0.295497932,
0.30876663400000004,
0.29106116200000004
]
},
{
"command": "pnpr@main",
"mean": 0.29080814190000004,
"stddev": 0.005484627931241069,
"median": 0.29084769600000004,
"user": 0.19958005999999998,
"system": 0.5054282000000001,
"min": 0.279139486,
"max": 0.297251449,
"times": [
0.289092349,
0.292603043,
0.28841757500000004,
0.297251449,
0.294510019,
0.296879241,
0.294454755,
0.287787242,
0.279139486,
0.28794626
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.8452829445799999,
"stddev": 0.01501342526152376,
"median": 1.84772933668,
"user": 0.8736952199999999,
"system": 0.74373616,
"min": 1.82260293218,
"max": 1.86513021218,
"times": [
1.84688860518,
1.86513021218,
1.82757573318,
1.83561525718,
1.8315731851800001,
1.85706067418,
1.8578896041800002,
1.8485700681800001,
1.85992317418,
1.82260293218
]
},
{
"command": "pacquet@main",
"mean": 1.84641329448,
"stddev": 0.007097160343547886,
"median": 1.84828042218,
"user": 0.9040929199999999,
"system": 0.7147424599999999,
"min": 1.83448370418,
"max": 1.85537577518,
"times": [
1.83842554018,
1.85108995718,
1.8472244741800001,
1.83946045418,
1.8511264251800001,
1.85399217018,
1.85537577518,
1.8493363701799999,
1.84361807418,
1.83448370418
]
},
{
"command": "pnpr@HEAD",
"mean": 0.29316882198000005,
"stddev": 0.0045413592549800146,
"median": 0.29368257868000003,
"user": 0.17570272,
"system": 0.52627666,
"min": 0.28565176218000005,
"max": 0.29986728718000005,
"times": [
0.29725005518000003,
0.29166605118000005,
0.29986728718000005,
0.28565176218000005,
0.29410426718000005,
0.29542651818000004,
0.28826701718000003,
0.29326089018,
0.28889561418000004,
0.29729875718000004
]
},
{
"command": "pnpr@main",
"mean": 0.29370237798,
"stddev": 0.004669445826725195,
"median": 0.29392129468000006,
"user": 0.18163792,
"system": 0.54919636,
"min": 0.28547923918,
"max": 0.29933293718000004,
"times": [
0.29417991718000003,
0.29087130618,
0.29834159618000006,
0.29366267218000003,
0.29124528418,
0.29933293718000004,
0.29926038218,
0.28869056018000006,
0.29595988518000005,
0.28547923918
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.32468227214,
"stddev": 0.010145271758531844,
"median": 0.32223263044000006,
"user": 0.32202874,
"system": 0.05138676000000001,
"min": 0.31001277144000006,
"max": 0.34099949244000005,
"times": [
0.33670122144000003,
0.31866617144000003,
0.33410323444000006,
0.32151274244000005,
0.34099949244000005,
0.31361074244000003,
0.31970092844000003,
0.32856289844000003,
0.32295251844000006,
0.31001277144000006
]
},
{
"command": "pacquet@main",
"mean": 0.3276684393400001,
"stddev": 0.011702650888147577,
"median": 0.32918063444000006,
"user": 0.32117193999999993,
"system": 0.05541545999999999,
"min": 0.31335515344000003,
"max": 0.34404787244000007,
"times": [
0.31743378144000006,
0.31335515344000003,
0.31751841044000007,
0.34135776444000004,
0.33518888844000005,
0.34404787244000007,
0.33348691044000006,
0.32487435844000007,
0.31356326244000005,
0.33585799144000006
]
},
{
"command": "pnpr@HEAD",
"mean": 0.08466750917529411,
"stddev": 0.0022143137137166416,
"median": 0.08487385744,
"user": 0.020253681176470584,
"system": 0.00822489176470588,
"min": 0.08135845344,
"max": 0.08875771344,
"times": [
0.08237086944000001,
0.08333352244,
0.08677249544,
0.08390261844,
0.08630901644,
0.08594517444000001,
0.08364793244,
0.08798727944,
0.08682913044,
0.08139624444,
0.08285230044,
0.08135845344,
0.08416688344,
0.08729116544,
0.08875771344,
0.08493579344,
0.08184611744,
0.08430809744000001,
0.08543349644,
0.08163154444,
0.08507060644,
0.08764346644,
0.08481192144000001,
0.08238330344,
0.08736618644000001,
0.08633221944,
0.08259155344,
0.08161667744000001,
0.08503077244,
0.08729623444,
0.08668986044,
0.08606666244,
0.08201913044,
0.08270086844
]
},
{
"command": "pnpr@main",
"mean": 0.08358421234909091,
"stddev": 0.0021547606669308334,
"median": 0.08269225144,
"user": 0.01977884606060606,
"system": 0.008143077575757576,
"min": 0.08053523244,
"max": 0.08864413044,
"times": [
0.08562597744,
0.08237686044,
0.08448215444,
0.08715139444,
0.08632203044,
0.08053523244,
0.08352796644,
0.08799796044000001,
0.08602930144,
0.08296036344,
0.08864413044,
0.08643207644,
0.08267371744,
0.08609245944,
0.08253616844,
0.08217626644,
0.08156619144,
0.08187940944,
0.08265623344,
0.08216629744000001,
0.08299925644,
0.08153669644,
0.08292804444,
0.08269225144,
0.08161658744,
0.08218626344,
0.08169151644,
0.08260190244,
0.08144262044,
0.08293944544,
0.08343330944,
0.08654727144,
0.08183165044
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.485398917820001,
"stddev": 0.13196650756404427,
"median": 4.4277525861200004,
"user": 1.7011720799999999,
"system": 1.3825740599999998,
"min": 4.39642077462,
"max": 4.807990327620001,
"times": [
4.39642077462,
4.432318474620001,
4.43361872962,
4.41192554662,
4.63104645762,
4.417090330620001,
4.421657214620001,
4.807990327620001,
4.42318669762,
4.47873462462
]
},
{
"command": "pacquet@main",
"mean": 4.522797278920001,
"stddev": 0.13115826200199132,
"median": 4.45658759062,
"user": 1.72009148,
"system": 1.36803826,
"min": 4.42642900362,
"max": 4.82985240162,
"times": [
4.45091120862,
4.42642900362,
4.67694705162,
4.44340540562,
4.53006823862,
4.82985240162,
4.43824852862,
4.4523349236200005,
4.46084025762,
4.5189357696200005
]
},
{
"command": "pnpr@HEAD",
"mean": 3.4719169295200003,
"stddev": 0.03397079952081103,
"median": 3.47129310512,
"user": 1.1803004799999999,
"system": 1.2233330599999999,
"min": 3.42973043562,
"max": 3.54342522562,
"times": [
3.4749041686199997,
3.42973043562,
3.44897385962,
3.44844866762,
3.43516307162,
3.49161159662,
3.54342522562,
3.48616394062,
3.49306628762,
3.46768204162
]
},
{
"command": "pnpr@main",
"mean": 3.4710989008199995,
"stddev": 0.05473701225442561,
"median": 3.4563921886199998,
"user": 1.1811484799999998,
"system": 1.22555186,
"min": 3.42715930362,
"max": 3.61845359062,
"times": [
3.47245510562,
3.45687525862,
3.43749901362,
3.42715930362,
3.45573397162,
3.61845359062,
3.45590911862,
3.47709768362,
3.47681937362,
3.43298658862
]
}
]
} |
|
| Branch | pr/13130 |
| 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 | 1,388.38 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 285.65 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 291.06 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 81.36 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,420.98 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,429.73 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 265.05 ms |
|
Thanks for working on this and for noting the existing assignment. I am closing this as a duplicate of #13131. The core Written by an agent (Codex, GPT-5). |
Closes #13105
Summary
The cache-race tests in
fetch_full_metadata_cached/tests.rssimulate a vanishing mirror from inside a mockito response closure, usingstd::fs::remove_file(&raced_mirror).expect("remove raced mirror"). The mock is declared.expect(1), so on the happy path the closure runs once and this is fine.But if the code under test regresses and the mock is hit a second time, the second
remove_filecall fails withNotFoundand panics — on mockito's server thread, duringServerGuardcleanup. That panic occurs while unwinding through aRwLockguard drop inServer::reset, poisoning the lock and triggering a second panic — a panic during a panic, which Rust cannot unwind through, so the process aborts (SIGABRTon Linux, stack-buffer-overrun on Windows) instead of the test failing cleanly.cargo nextestthen cancels any sibling tests still running.This is a diagnostics-only issue — the regression is still caught (confirmed by mutating
fetch_full_metadata_cached.rs:123tobypass_cache: falseand observing the abort) — but the failure signal is far worse than a clean assertion.Squash Commit Body
Checklist
The change is implemented in both the TypeScript CLI and the Rust
pnpm/port, or the description notes what still needs porting.Rust-only change (test-file fix in
pacquet-resolving-npm-resolver); no TypeScript equivalent exists for this test infrastructure.Added a changeset (
pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
No changeset — this only touches test code, no published package behavior changes.
Added or updated tests.
No new tests added; existing tests' failure-mode fixed. Verified via
cargo nextest run -p pacquet-resolving-npm-resolver cache_loss(5/5 pass) and by re-simulating the original regression to confirm the fix produces a clean failure instead of an abort.Updated the documentation if needed.
No doc update needed — internal test-infrastructure fix only.
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by CodeRabbit