fix(arborist): record the linked .store layout in the hidden lockfile#9630
Merged
owlstronaut merged 1 commit intoJun 24, 2026
Merged
Conversation
f6abc1b to
658c010
Compare
658c010 to
f723efa
Compare
owlstronaut
approved these changes
Jun 24, 2026
Contributor
|
This usually means the cherry-pick had conflicts. Please create a manual backport: git fetch origin release/v11
git checkout -b backport/v11/9630 origin/release/v11
git cherry-pick -x 696801574984ad19ffaa9a7200d7e752920a018d
# resolve any conflicts, then:
git push origin backport/v11/9630Error details |
Contributor
Author
|
Creating a manual backport for this... |
Contributor
Author
|
Here you go #9642 |
owlstronaut
pushed a commit
that referenced
this pull request
Jun 24, 2026
… (backport #9630) (#9642) Backport of #9630 to `release/v11`. Under `install-strategy=linked`, the hidden lockfile `node_modules/.package-lock.json` recorded the hoisted logical layout instead of the on-disk `.store`/symlink layout, so it was rejected on every reload and never served as the actual-tree cache it is meant to be. ## How `reify.js` serializes the hidden lockfile from the isolated tree, which mirrors the on-disk layout, while `package-lock.json` still comes from the logical tree. `assertNoNewer()` additionally validates the store package node_modules and undeclared-workspace subtrees that the plain `node_modules` walk cannot reach under the linked strategy, gated so the hoisted strategy keeps its existing, stricter validation. The original commit's change to `test/arborist/reify-npm-extension.js` was dropped because the `.npm-extension` feature does not exist on `release/v11`. ## References Backport of #9630 Part of #9608
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In continuation of our exploration of using
install-strategy=linkedin the Gutenberg monorepo, which powers the WordPress Block Editor.Under
install-strategy=linked, the hidden lockfilenode_modules/.package-lock.jsonrecorded the hoisted logical layout (node_modules/<pkg>) instead of the actual on-disk.store/symlink layout. The hidden lockfile is meant to cache whatloadActual()finds on disk so the actual tree can be validated cheaply, but because it recorded the wrong layout it was rejected on every reload, so it never served as a cache and misrepresented the installed layout.Why
A linked reify swaps
idealTreefor the isolated tree, materializes the.store/symlink layout, then swaps the logical tree back before saving. The hidden lockfile was serialized from that logical tree, so it listed packages at their hoisted paths. On the next load,assertNoNewer()walked the realnode_modules(the root symlink plus.store/) and could not reconcile it with the hoisted entries, throwingmissing from lockfile, soloadActual()always fell back to a full filesystem scan.How
reify.jsserializes the hidden lockfile from the isolated tree, which mirrors the on-disk layout, whilepackage-lock.jsonstill comes from the logical tree. It records every store package directory and symlink, adds an entry for each.store/<key>container directory (these are the fsParentsloadVirtual()needs so a store package can resolve its sibling deps), includes the workspace directories, and skips tree-only undeclared-workspace self-links that are never materialized on disk.assertNoNewer()additionally validates the directories the plainnode_moduleswalk cannot reach under the linked strategy: a store package's deps live as symlinked siblings under.store/<key>/node_modules(and.storeis skipped as a dot-dir), and an undeclared workspace is not symlinked into the rootnode_modulesat all. These directories are derived from the lockfile entries. A workspace directory is only walked when it is not the target of a link entry, so the hoisted strategy keeps its existing, stricter validation unchanged — a stale workspace symlink that points at the wrong target still surfaces as a missing entry and rejects the cache.References
Fixes #9612
Part of #9608