Repository navigation
fix(store-dir): rebuild when the side-effects cache has nothing to restore - #14744
Conversation
|
Warning Review limit reachedNext included review available in 11 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe side-effects cache now treats empty diffs as cache misses. Packages with no in-package build output run their build scripts during installation, including frozen reinstalls. Unit and end-to-end tests cover this behavior. ChangesSide-effects cache fix
Estimated code review effort: 2 (Simple) | ~15 minutes Severity of issue fixed: Medium Assessment against linked issues
Suggested labels: Merge Risk: ⚪ Minimal · up to Dependencies whose build scripts produce no package-directory output now rebuild instead of being incorrectly treated as restored cache hits, while deletion-only and normal cache restoration behavior remain covered. No current merge-blocking risk is identified. ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 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 |
Micro-Benchmark ResultsLinux |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14744 +/- ##
==========================================
+ Coverage 90.43% 90.52% +0.08%
==========================================
Files 796 796
Lines 155522 155540 +18
==========================================
+ Hits 140653 140802 +149
+ Misses 14869 14738 -131 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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. 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.31443907044,
"stddev": 0.1064085247122949,
"median": 2.2715351878399996,
"user": 1.22011936,
"system": 1.42987436,
"min": 2.24296162334,
"max": 2.55932251834
},
{
"command": "pacquet@main",
"mean": 2.37812706544,
"stddev": 0.15522783031727835,
"median": 2.30157980184,
"user": 1.21231846,
"system": 1.40662546,
"min": 2.2314719363399997,
"max": 2.6154829723399997
},
{
"command": "pnpr@HEAD",
"mean": 1.41262248504,
"stddev": 0.09125086509476205,
"median": 1.3961747283400001,
"user": 1.1263315600000001,
"system": 1.26824166,
"min": 1.29403394434,
"max": 1.60619778634
},
{
"command": "pnpr@main",
"mean": 1.4030398726400002,
"stddev": 0.13246560444650446,
"median": 1.3562037443400001,
"user": 1.08584696,
"system": 1.2603995599999998,
"min": 1.2901667783400002,
"max": 1.6667608413400001
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.21002996266,
"stddev": 0.006312776616956831,
"median": 0.21074296146000002,
"user": 0.21026993999999996,
"system": 0.5107346199999999,
"min": 0.19855887196000002,
"max": 0.21935056396000002
},
{
"command": "pacquet@main",
"mean": 0.21651011086,
"stddev": 0.008120750275835071,
"median": 0.21724177496000002,
"user": 0.23040084,
"system": 0.49802292000000004,
"min": 0.20645845696,
"max": 0.23001508296
},
{
"command": "pnpr@HEAD",
"mean": 0.22430277646000002,
"stddev": 0.009212855673837924,
"median": 0.22313384696000002,
"user": 0.22172424,
"system": 0.48490041999999994,
"min": 0.21171368496,
"max": 0.23913721796
},
{
"command": "pnpr@main",
"mean": 0.22820182346,
"stddev": 0.008000523017735878,
"median": 0.22790374396000002,
"user": 0.21953333999999997,
"system": 0.50946752,
"min": 0.21349542696,
"max": 0.24321332196
}
]
}Scenario: Isolated linker: repeat install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.007291886018257263,
"stddev": 0.0009186671855866406,
"median": 0.0072147084,
"user": 0.00374862398340249,
"system": 0.00400783502074689,
"min": 0.0056655614,
"max": 0.0113487394
},
{
"command": "pacquet@main",
"mean": 0.0068382081493112935,
"stddev": 0.000363640511279907,
"median": 0.006823389400000001,
"user": 0.004161598732782374,
"system": 0.0031239887603305783,
"min": 0.0060311724,
"max": 0.0086366164
},
{
"command": "pnpr@HEAD",
"mean": 0.006355572149999996,
"stddev": 0.0005793582054916143,
"median": 0.0062232349,
"user": 0.004090919010989012,
"system": 0.002649534065934067,
"min": 0.005666514400000001,
"max": 0.0096168084
},
{
"command": "pnpr@main",
"mean": 0.006392327042857139,
"stddev": 0.0006184162070986796,
"median": 0.0062480374,
"user": 0.0038564146938775516,
"system": 0.0029216725510204096,
"min": 0.0056404544,
"max": 0.0097946524
}
]
}Scenario: Isolated linker: repeat install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.007075279726517577,
"stddev": 0.0012799226121946112,
"median": 0.006549784800000001,
"user": 0.00430149130990415,
"system": 0.0031711556549520784,
"min": 0.0057410658,
"max": 0.013635200800000002
},
{
"command": "pacquet@main",
"mean": 0.007286257394029854,
"stddev": 0.0013568016286974757,
"median": 0.0068680558,
"user": 0.004274851044776118,
"system": 0.003408752417910449,
"min": 0.0057310768,
"max": 0.013802476800000001
},
{
"command": "pnpr@HEAD",
"mean": 0.008108281596721313,
"stddev": 0.0012079201323722155,
"median": 0.007909092800000002,
"user": 0.004700122295081966,
"system": 0.0038607578360655764,
"min": 0.0059234218,
"max": 0.014041166800000001
},
{
"command": "pnpr@main",
"mean": 0.008096046344850503,
"stddev": 0.0006151568123638037,
"median": 0.0079831928,
"user": 0.004517677940199337,
"system": 0.003995195880398671,
"min": 0.006800147800000001,
"max": 0.011335485800000001
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.4316648147600004,
"stddev": 0.02248084418954723,
"median": 2.42434222326,
"user": 1.6319495400000001,
"system": 1.46859278,
"min": 2.40754573926,
"max": 2.48110046726
},
{
"command": "pacquet@main",
"mean": 2.4223813636600005,
"stddev": 0.006995885633390768,
"median": 2.42424600626,
"user": 1.5264397400000003,
"system": 1.4725717800000002,
"min": 2.41126541626,
"max": 2.43351802826
},
{
"command": "pnpr@HEAD",
"mean": 1.44838017076,
"stddev": 0.1134070862387833,
"median": 1.38548002976,
"user": 0.9814207399999999,
"system": 1.20158938,
"min": 1.36580159126,
"max": 1.6582520912599998
},
{
"command": "pnpr@main",
"mean": 1.4732204976599999,
"stddev": 0.13283064573037204,
"median": 1.4378214537599998,
"user": 0.9966120399999999,
"system": 1.1660885799999998,
"min": 1.35627559326,
"max": 1.71387838526
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.34080406364,
"stddev": 0.013684923994727864,
"median": 0.34039064594,
"user": 0.46769969999999994,
"system": 0.7598838600000002,
"min": 0.31069388994,
"max": 0.36342481494
},
{
"command": "pacquet@main",
"mean": 0.32883021164000004,
"stddev": 0.008805425956522584,
"median": 0.32759043394,
"user": 0.46338280000000004,
"system": 0.7494818599999999,
"min": 0.31516800894,
"max": 0.34342783894
},
{
"command": "pnpr@HEAD",
"mean": 0.25660523634,
"stddev": 0.011036955204696546,
"median": 0.25633452044,
"user": 0.1746476,
"system": 0.47327975999999994,
"min": 0.24245682494000004,
"max": 0.27358372294
},
{
"command": "pnpr@main",
"mean": 0.25298579733999993,
"stddev": 0.005167271445160262,
"median": 0.25241997444,
"user": 0.17509129999999998,
"system": 0.46768925999999994,
"min": 0.24649632794000004,
"max": 0.26238580694
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.53203795712,
"stddev": 0.011842697272201665,
"median": 1.53545808222,
"user": 0.7202153399999999,
"system": 0.87814056,
"min": 1.50918728872,
"max": 1.55375167572
},
{
"command": "pacquet@main",
"mean": 1.5194251677200001,
"stddev": 0.010582154152337332,
"median": 1.51787010872,
"user": 0.69461694,
"system": 0.85156376,
"min": 1.50571074072,
"max": 1.54367539772
},
{
"command": "pnpr@HEAD",
"mean": 0.27565847722000003,
"stddev": 0.02224142508250127,
"median": 0.26971693322,
"user": 0.21216054,
"system": 0.48905985999999996,
"min": 0.25059894272,
"max": 0.32077759172000003
},
{
"command": "pnpr@main",
"mean": 0.27123224472,
"stddev": 0.01334262196542288,
"median": 0.26535324822000006,
"user": 0.19030403999999995,
"system": 0.47730606,
"min": 0.25753684072,
"max": 0.29177180072000003
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.19857902705384617,
"stddev": 0.006949062880478598,
"median": 0.1972453489,
"user": 0.2110014153846154,
"system": 0.07436501846153847,
"min": 0.1880152199,
"max": 0.21595396490000002
},
{
"command": "pacquet@main",
"mean": 0.1953237196857143,
"stddev": 0.018644168677896766,
"median": 0.1940493359,
"user": 0.19556472857142854,
"system": 0.06111776571428572,
"min": 0.1713844099,
"max": 0.23383508690000002
},
{
"command": "pnpr@HEAD",
"mean": 0.09175187541612903,
"stddev": 0.001985132002774978,
"median": 0.0918733399,
"user": 0.03233205806451613,
"system": 0.014387189677419357,
"min": 0.08719095290000001,
"max": 0.09639898090000001
},
{
"command": "pnpr@main",
"mean": 0.0876249172870968,
"stddev": 0.0010114196006592803,
"median": 0.08735681690000001,
"user": 0.028886638709677417,
"system": 0.013761544516129034,
"min": 0.0867603509,
"max": 0.0914935129
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6725768246377778,
"stddev": 0.07779619642497727,
"median": 0.70864582086,
"user": 0.6737512044444444,
"system": 0.17076769777777778,
"min": 0.5761695198600001,
"max": 0.7546387788600001
},
{
"command": "pacquet@main",
"mean": 0.6623329555266667,
"stddev": 0.07776154393910405,
"median": 0.69553983586,
"user": 0.6670694266666666,
"system": 0.14312825333333332,
"min": 0.54005885486,
"max": 0.7541503258600001
},
{
"command": "pnpm@HEAD",
"mean": 3.0477554001933336,
"stddev": 0.06208000821222307,
"median": 3.05461375786,
"user": 4.734293093333333,
"system": 0.26869103111111114,
"min": 2.9301293298599997,
"max": 3.12775222186
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.4216649852,
"stddev": 0.16158386461022212,
"median": 4.390985624099999,
"user": 1.35564564,
"system": 1.41433348,
"min": 4.2557465731,
"max": 4.729451325099999
},
{
"command": "pacquet@main",
"mean": 4.379220421199999,
"stddev": 0.14218159273893677,
"median": 4.3081443041,
"user": 1.28427814,
"system": 1.38288978,
"min": 4.283261803099999,
"max": 4.7025592641
},
{
"command": "pnpr@HEAD",
"mean": 3.4614104404000003,
"stddev": 0.13595265268770945,
"median": 3.4045462146,
"user": 1.22490634,
"system": 1.3103336799999998,
"min": 3.3308352091,
"max": 3.6957049171
},
{
"command": "pnpr@main",
"mean": 3.4299819936000007,
"stddev": 0.11933324611245728,
"median": 3.3825515611,
"user": 1.23652244,
"system": 1.3274274799999999,
"min": 3.3432925361000003,
"max": 3.7227875701
}
]
}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. Comparable to that scenario head-to-head.
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.12187097794363634,
"stddev": 0.004826239263873835,
"median": 0.12062623357999999,
"user": 0.16299387818181818,
"system": 0.15555168909090908,
"min": 0.11500462158000001,
"max": 0.13577190158000002
},
{
"command": "pacquet@main",
"mean": 0.12391290067090908,
"stddev": 0.004780262410509496,
"median": 0.12353871708,
"user": 0.16672306,
"system": 0.16145050727272722,
"min": 0.11511437958,
"max": 0.13206537858
},
{
"command": "pnpr@HEAD",
"mean": 0.1389685147466667,
"stddev": 0.00423667559494148,
"median": 0.13830019308000002,
"user": 0.1781209488888889,
"system": 0.15664016888888888,
"min": 0.13138357958000002,
"max": 0.14706272358000003
},
{
"command": "pnpr@main",
"mean": 0.14778640822705885,
"stddev": 0.01629274044072825,
"median": 0.14600632858,
"user": 0.18285361882352943,
"system": 0.16427151529411765,
"min": 0.12981902458000003,
"max": 0.19084721458
}
]
} |
c9a79da to
0dadabc
Compare
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.
🟢 Approval recommended
The functional change is well-scoped, aligns v12 with v11 semantics for empty side-effects rows, and is covered by targeted unit + e2e regression tests.
Pull request overview
Fixes pacquet (pnpm v12) side-effects cache behavior so a “cache hit” only counts when there is actual in-package build output to restore; otherwise the importer must rebuild (matching pnpm v11 behavior). This addresses cases where build scripts have effects entirely outside the package directory (e.g. git-hook installers), which previously could be skipped with no materialization.
Changes:
- Drop side-effects cache rows whose diff has nothing to restore (no
addedand nodeleted), preventing false-positive “already built” decisions. - Add unit coverage in
store-dirfor empty-row drop behavior and “deletions-only” rows remaining valid hits. - Add an e2e fixture and regression test ensuring such builds re-run on consecutive installs.
File summaries
| File | Description |
|---|---|
pnpr/.fixtures/packages/@pnpm.e2e/postinstall-writes-outside-package/1.0.0/package.json |
Adds a fixture package whose postinstall writes outside its own directory to reproduce the empty-diff scenario. |
pnpm/crates/store-dir/src/check_pkg_files_integrity.rs |
Drops empty side-effects rows during overlay materialization so is_built isn’t satisfied by a no-op overlay. |
pnpm/crates/store-dir/src/check_pkg_files_integrity/tests.rs |
Adds unit tests to pin empty-row drop semantics and preserve deletions-only behavior. |
pnpm/crates/cli/tests/suite/side_effects_cache.rs |
Adds an e2e regression test asserting the postinstall runs on multiple installs when nothing can be restored from the cache. |
.changeset/side-effects-cache-empty-overlay.md |
Adds a user-facing release note for the v12 fix. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🟢 Approval recommended
The behavioral change is narrowly scoped, well-tested (unit + e2e), and aligns pacquet with pnpm 11’s handling of empty side-effects rows.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
pnpr/.fixtures/packages/@pnpm.e2e/postinstall-writes-outside-package/1.0.0/package.json:6
- The
postinstallscript uses single quotes around thenode -esnippet, which can be brittle across shells (and differs from other fixtures here that usenode -e "..."). Prefer double quotes around the-epayload and use single quotes inside the JS for consistency and better portability.
- Files reviewed: 5/5 changed files
- Comments generated: 0 new
- Review effort level: Lite
325d054 to
2f211ea
Compare
Code Review by Qodo
1.
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
2f211ea to
eff8032
Compare
|
Code review by qodo was updated up to the latest commit eff8032 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
| Project | pnpm's project |
| Branch | pr/14744 |
| 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) |
|---|---|---|
| gvs-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 131.38 ms |
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 1,365.80 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 250.60 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 242.46 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 87.19 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,294.03 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,330.84 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 211.71 ms |
| isolated-linker.repeat-install.cold-cache.hot-store | 📈 view plot | 5.92 ms |
| isolated-linker.repeat-install.hot-cache.hot-store | 📈 view plot | 5.67 ms |
…store A side-effects row is recorded whenever a build script ran, including a build that changed nothing inside the package directory. `calculate_diff` returns `added: None, deleted: None` for that case and the row is stored anyway, so a package whose whole build effect lands elsewhere -- a git-hook installer, a script seeding a shared download cache -- gets an empty row. `build_side_effects_maps` turned every row into an overlay, so an empty one became an overlay equal to the base files and the `is_built` gate took it as a hit. The scripts were skipped and nothing was materialized in their place: the package directory after such an install is byte-identical to the pristine tarball, and the build's effect never happens at all. The cache key does not include the consuming project, so this is not limited to reinstalls -- a project's first install can hit a row an unrelated project seeded on the same machine. pnpm 11 drops the row instead. Its `checkPkgFilesIntegrity` adds to `sideEffectsMaps` only under `if (added) ... else if (deleted)`, so an empty row matches neither branch, `sideEffectsCacheKey` is never set, `isBuilt` stays false, and the build runs. Both stacks write the same empty row and only their read paths differed, so this drops it at the same point pnpm 11 does. An entry's presence now means there is build output to materialize, which is what the `is_built` gate already assumed. A row carrying only `deleted` still counts as a hit. That build did happen and its effect is reproducible from the row. `prefetch.rs` already filters an empty `side_effects_maps` out of the prefetch result, so a package whose only row is dropped contributes no entry at all and the frozen-install fast path in `build_phase` still sees an empty table. Closes #14717
Use `is_none_or(is_empty)` for the empty-diff check. It is the idiom the rest of the workspace uses for exactly this shape, including `build_phase.rs` in the subsystem this gate feeds. Strip the ambient pnpm configuration from the `Command`s these tests spawn directly. `CommandTempCwd` already does this for the commands it builds, so the installs after the first were the only ones in the file still inheriting `PNPM_CONFIG_*` from the developer's shell or from CI -- including `PNPM_CONFIG_SIDE_EFFECTS_CACHE`, which decides the behavior under test. `run_frozen_install` had the same gap and gets the same treatment: it drives the two tests that guard against this fix dropping too much, so it has to be the one deciding the config.
Quote the fixture's `node -e` payload the way the sibling fixtures do so it also runs under cmd.exe, state the empty-row rationale once in `overlay_for` instead of in three places, share the frozen-install command between the e2e tests, and lead the changeset with the user-visible change. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QpL16HSRQRoLWd3vgoKXt5
…s cache The empty-row guard lived only in the store-index read path. The shared remote cache bypassed it on both sides: the publisher uploaded an artifact for any build, including one whose diff names no files, and `apply_resolved_artifact` staged such an artifact as a base-only overlay that the build phase took as a hit. Dropping the persisted row only sent the consumer back to the server for the same empty artifact. `SideEffectsDiff::is_empty` now carries the rule once. `overlay_for` and the publisher use it, and the publisher returns early instead of uploading. `ArtifactManifest::is_empty` guards the consumer before any blob is downloaded, which also covers artifacts older versions already published. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01QpL16HSRQRoLWd3vgoKXt5
eff8032 to
fcef09d
Compare
|
Code review by qodo was updated up to the latest commit fcef09d |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
…store (pnpm#14744) A side-effects row is recorded whenever a build script ran, including a build that changed nothing inside the package directory. `calculate_diff` returns `added: None, deleted: None` for that case and the row is stored anyway, so a package whose whole build effect lands elsewhere -- a git-hook installer, a script seeding a shared download cache -- gets an empty row. `build_side_effects_maps` turned every row into an overlay, so an empty one became an overlay equal to the base files and the `is_built` gate took it as a hit. The scripts were skipped and nothing was materialized in their place: the package directory after such an install is byte-identical to the pristine tarball, and the build's effect never happens at all. The cache key does not include the consuming project, so this is not limited to reinstalls -- a project's first install can hit a row an unrelated project seeded on the same machine. pnpm 11 drops the row instead. Its `checkPkgFilesIntegrity` adds to `sideEffectsMaps` only under `if (added) ... else if (deleted)`, so an empty row matches neither branch, `sideEffectsCacheKey` is never set, `isBuilt` stays false, and the build runs. Both stacks write the same empty row and only their read paths differed, so this drops it at the same point pnpm 11 does. An entry's presence now means there is build output to materialize, which is what the `is_built` gate already assumed. A row carrying only `deleted` still counts as a hit. That build did happen and its effect is reproducible from the row. `prefetch.rs` already filters an empty `side_effects_maps` out of the prefetch result, so a package whose only row is dropped contributes no entry at all and the frozen-install fast path in `build_phase` still sees an empty table. Closes pnpm#14717 --------- Co-authored-by: Zoltan Kochan <[email protected]>
…15859) On Windows the post-build rehash cannot see the mode stored from the tarball. pnpm 12 reports a fixed 0o644 and pnpm 11 reports the mode from fs.stat (0o666, or 0o444 for a read-only file). The side-effects diff treated that difference as an added file, so the row was never empty. Both stacks rebuild only when the row has nothing to restore (#14744 for pnpm 12). A build whose whole effect lies outside the package directory, such as a git hook installer, was treated as a cache hit and skipped. Compare modes only where the rehash can observe them. Closes #15667 --------- Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: Gabriel Mari S. Flores <[email protected]>
…#16843) A rebuild with skipIfHasSideEffectsCache still ran the build of a package whose side-effects row is empty: a build that changed nothing inside the package, such as ssh2's install script when its optional native binding cannot compile. Since #14744 the store's read path drops empty rows from the overlays, so the is_built gate never sees them, and such a package ran its script on every rebuild. An embedder that installs without a modules directory and then rebuilds the pending packages re-ran these scripts each time. pnpm v11's rebuild checks only that the store index has a row for the cache key (`pkgFilesIndex.sideEffects.has(key)`), empty or not. This matches it: the build phase now also gets the raw rows, and a rebuild with skip_if_has_side_effects_cache treats an empty row for the key as built, with nothing to materialize, unless the package directory carries the build marker of a global virtual store slot that was never built. The dependency graph is built for the gate when such rows exist even if no overlay does. The overlays and the rows travel together as CachedSideEffects. An install keeps running these builds, since their effect may lie outside the package directory (#14717).
The loaded linker sent a build that changed nothing inside its package to the global virtual store. pnpm drops an empty side-effects row on read since pnpm#14744, so such a build never counted as a cache hit and its package, with its whole dependency tree, got a directory. Real packages hit this often: es5-ext's postinstall only prints a message. The loaded linker, which is experimental, now restores an empty row as an overlay of the package's pristine files, both from the store index and right after a temporary build. Other projects that share the store reuse the build without running its script, which matches how a shared global virtual store directory already behaves. sideEffectsCache.exclude is the opt-out for a script that must run in every project, and an excluded package no longer goes through a temporary build. The other linkers keep dropping empty rows; making them cache too is planned for the next major in pnpm/tasks#242. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The loaded linker sent a build that changed nothing inside its package to the global virtual store. pnpm drops an empty side-effects row on read since pnpm#14744, so such a build never counted as a cache hit and its package, with its whole dependency tree, got a directory. Real packages hit this often: es5-ext's postinstall only prints a message. The loaded linker, which is experimental, now restores an empty row as an overlay of the package's pristine files, both from the store index and right after a temporary build. Other projects that share the store reuse the build without running its script, which matches how a shared global virtual store directory already behaves. sideEffectsCache.exclude is the opt-out for a script that must run in every project, and an excluded package no longer goes through a temporary build. The other linkers keep dropping empty rows; making them cache too is planned for the next major in pnpm/tasks#242. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The loaded linker sent a build that changed nothing inside its package to the global virtual store. pnpm drops an empty side-effects row on read since pnpm#14744, so such a build never counted as a cache hit and its package, with its whole dependency tree, got a directory. Real packages hit this often: es5-ext's postinstall only prints a message. The loaded linker, which is experimental, now restores an empty row as an overlay of the package's pristine files, both from the store index and right after a temporary build. Other projects that share the store reuse the build without running its script, which matches how a shared global virtual store directory already behaves. sideEffectsCache.exclude is the opt-out for a script that must run in every project, and an excluded package no longer goes through a temporary build. The other linkers keep dropping empty rows; making them cache too is planned for the next major in pnpm/tasks#242. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…7318) * feat(store-loader): complete temporary builds and materialization * fix(store-loader): remove obsolete cycle cache warmup * fix(store-loader): keep cache keys for snapshots outside a temporary build The temporary-build pass handed the later materialization pass cache keys for its build candidates only. A cold snapshot outside them, such as a `nodeLinker.excluded` package, then hit the "derived a cache key for every lockfile snapshot" panic. The handoff now keeps the keys of every retained snapshot. Also: - proceed unserialized when the global virtual store slot lock is not available, as the lock's other callers do; - rename the output `SnapshotSelection` to `SnapshotPlacement`, which no longer shares a name with the input selection; - merge the two overlapping changesets and stop describing approved cache misses as materialized; - restore the doc comments dropped from retained items. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(store-loader): carry the final loaded selection into the build phase The loaded linker's output covered only the snapshots its materialization pass installed. The build metadata of loaded and promoted snapshots now comes from the fetch pass, so the list of dependencies requiring a build includes them. The build phase's post-build bin relinking now sees every physical snapshot, including those materialized automatically, not only the `nodeLinker.excluded` closure. The changeset now qualifies which builds run in a temporary directory and says the filesystem-access scan misses computed imports. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(store-loader): keep a rebuilt slot's withheld cache overlay withheld Merging the fetch pass's side-effects overlays into the loaded linker's output restored the overlay the materialization pass withholds from a slot that must be rebuilt, such as one with a build marker. The build phase then took the cached output and skipped the lifecycle scripts. The fetch pass now fills in build metadata only for the snapshots the materialization pass did not install. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(store-loader): stop merging fetch-pass build metadata into the output Filling in `requiresBuild` and the side-effects overlays of the loaded and promoted snapshots from the fetch pass exposed them to the build phase. Under the global virtual store, the build phase resolves every snapshot to its slot path whether or not the slot exists. A CAS-loaded build package then became a build candidate for a slot the loaded linker never created. The output again carries the materialization pass's metadata only. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(store-loader): report loaded build packages as requiring a build The list of dependencies requiring a build came from the build phase's `requiresBuild` map. That map covers only the snapshots the loaded linker materialized, so CAS-loaded and promoted build packages were left out. They are now recorded on the snapshot placement and added to the reported list. The build phase still never sees them. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(store-loader): load builds that change no package files from CAS The loaded linker sent a build that changed nothing inside its package to the global virtual store. pnpm drops an empty side-effects row on read since #14744, so such a build never counted as a cache hit and its package, with its whole dependency tree, got a directory. Real packages hit this often: es5-ext's postinstall only prints a message. The loaded linker, which is experimental, now restores an empty row as an overlay of the package's pristine files, both from the store index and right after a temporary build. Other projects that share the store reuse the build without running its script, which matches how a shared global virtual store directory already behaves. sideEffectsCache.exclude is the opt-out for a script that must run in every project, and an excluded package no longer goes through a temporary build. The other linkers keep dropping empty rows; making them cache too is planned for the next major in pnpm/tasks#242. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(store-loader): reuse a dependency's empty build in a temporary build A temporary build takes its side-effects overlays from its own pass, which reads the retained prefetch rows. Those rows still dropped an empty build, so a cache miss that depends on a package whose build changed no files ran that dependency's script again. The overlays that restore_empty_builds adds now go to the retained prefetch as well, the way an overlay captured after a temporary build already does. The later passes apply their own build-marker and sideEffectsCache.exclude checks to them. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(store-loader): restore empty builds in the partition restore_empty_builds added an overlay of the package's files for every snapshot whose row had an empty build, after the partition had already decided which snapshots' overlays to withhold. A peer variant with a build marker got the overlay anyway. Copying that variant's map into the retained prefetch row, which its peer variants share, could also drop an overlay another variant still needed. The partition now adds the overlay itself, for the snapshots it does not withhold, whenever the configured node linker is loaded. Every pass of a loaded install reads the shared rows the same way, so nothing rewrites them. After a temporary build, the captured result updates only its own cache key in the shared row. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(deps-restorer): import slot metadata types * fix(store-loader): align materialization with current APIs * fix(store-loader): satisfy Rust workspace checks * fix(deps-restorer): rerun builds without cached effects * fix(store-loader): keep junction links when promoting temporary builds Promoting a temporary build retargets the slot's dependency links. On Windows without symlink privileges those links are junctions, and recreating them through the plain symlink API failed. Directory links now go through the junction-aware helper, and the link target is compared without its verbatim prefix. Also replace the `restores_empty_builds` flag with an `EmptyBuilds` enum and log the store manifest in the loaded-linker build tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(store-loader): build in the global virtual store when a runtime is pinned A temporary build's graph holds only the built package's dependencies, so it ran on the host Node.js even when the root project pins one with a `runtime:` dependency. The result was still cached under the pinned runtime's engine. Such installs now skip temporary builds, and the packages build in the global virtual store on the pinned runtime. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(store-loader): honor --no-runtime and stop copying CAS file maps A pinned runtime that the install skips no longer turns temporary builds off, since builds then run on the host Node.js either way. The loader manifest now reads each package's CAS paths in place without copying them into an intermediate map. The changeset names pnpm as the actor that materializes packages. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Zoltan Kochan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
Closes #14717.
pnpm 12 skips a dependency's build scripts on a side-effects cache hit even when the matched cache row has nothing to restore, so the scripts don't run and nothing is materialized in their place. A build whose whole effect lands outside its own package directory — a git-hook installer, a script seeding a shared download cache — therefore never takes effect. pnpm 11 rebuilds in this case.
A row is recorded whenever a build script ran, and a build that changed nothing inside the package directory produces an empty one. Both stacks write that row; only the read paths differed:
checkPkgFilesIntegrity(store/cafs/src/checkPkgFilesIntegrity.ts:89) adds a row tosideEffectsMapsonly underif (added) … else if (deleted). An empty row matches neither branch, so it is dropped,sideEffectsCacheKeyis never set,isBuiltstaysfalse, and the build runs.build_side_effects_mapsturned every row into an overlay. An empty row became an overlay equal to the base files, and theis_builtgate took it as a hit.This PR drops the row at the same point pnpm 11 does. An entry's presence now means there is build output to materialize, which is what the
is_builtgate already assumed.The reproduction in the issue, run against this build:
On 12.3.2 project b's hook is
MISSING.Notes for reviewers
addedbeing absent. A row carrying onlydeletedstill counts as a hit: that build happened and its effect is reproducible from the row.side_effects_overlay_with_only_deletions_keeps_cache_key_entrypins that, so the fix can't quietly widen into "onlyaddedrows count."prefetch.rs:257already filters an emptyside_effects_mapsout of the prefetch result, so a package whose only row is dropped contributes no entry toside_effects_maps_by_snapshotand the frozen-install fast path atbuild_phase.rs:210still sees an empty table. I checked the remote path too:shared_side_effects.rsbuildsside_effects_maps_by_snapshotfrom resolved artifacts directly rather than throughbuild_side_effects_maps, so a remote artifact with real content is unaffected.remote_originset and noadded/deletedis dropped as well. Same reasoning, and it matches pnpm 11, whose check looks only atadded/deleted.pnpm11/. Verified by measurement rather than by reading — see the table below.Validation
Measured with one project per cell, a fresh store per pnpm version, and
node_moduleswiped between the two installs.ran / ranmeans the build script ran on both installs.The second row is the legitimate cache hit and still skips, with the cached file restored. Only the first row changes, and it now matches both pnpm 11 versions.
simple-git-hooksscenario against released 12.3.2 (project b's hook missing), then confirmed both projects get the hook with this build.a_build_with_nothing_to_restore_runs_on_every_install(e2e, asserts the postinstall runs on three consecutive installs), plusside_effects_overlay_with_nothing_to_restore_drops_cache_key_entryandside_effects_overlay_with_only_deletions_keeps_cache_key_entry(unit).@pnpm.e2e/postinstall-writes-outside-package, whose postinstall appends a byte to a file named by an env var and leaves its own directory untouched. Its diff is empty by construction, which is what the test needs.pnpm-store-dir,pnpm-deps-restorer, andpnpm-tarballin full (766 tests), and theside_effects_cache,lifecycle_scripts,global_virtual_store, andlocal_tarball_dependencymodules ofpnpm-cli(95 tests). Bothside_effects_materialized_on_warm_frozen_reinstallvariants pass, which are the tests that would catch an over-broad drop.cargo clippy --locked --workspace --all-targets -- -D warningsandRUSTDOCFLAGS=-D warnings cargo doc --workspace --no-depsare clean;cargo fmtandtaplo formatapplied.just readywas not runnable in this environment (justandtyposare not installed), so those steps are left to CI.Squash Commit Body
Checklist
already linked to it solves it.
are implemented in every affected version. (pnpm 11 already rebuilds in
this case, so there is nothing to fix there — see the table above.)
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-opus-5).
Summary by CodeRabbit
Bug Fixes
pnpm installnow reruns dependency build scripts when the side-effects cache has no files to restore.Tests