fix(arborist): skip postinstall on store links in linked strategy#9013
Open
manzoorwanijk wants to merge 2 commits intonpm:latestfrom
Open
fix(arborist): skip postinstall on store links in linked strategy#9013manzoorwanijk wants to merge 2 commits intonpm:latestfrom
manzoorwanijk wants to merge 2 commits intonpm:latestfrom
Conversation
…tegy The isStoreLink guard in rebuild.js was reading from node.target (the store entry) instead of node (the link), so it was always undefined. Both the store entry and its symlink ran scripts against the same directory in parallel, causing race conditions in packages like esbuild. Check node.isLink && node.target?.isInStore instead, which correctly skips store links while still running scripts for workspace links and store entries.
b689b16 to
1815776
Compare
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.
Continuing the
install-strategy=linkedfixes from #8996. While testing on the Gutenberg monorepo,esbuildinstalls fail because its postinstall script runs twice in parallel against the same store directory.Summary
With
install-strategy=linked, postinstall scripts run twice for every store package — once for the store entry and once for its symlink. For packages likeesbuildwhose postinstall modifies files in-place (fs.linkSyncto replace the JS wrapper with a native binary), this race condition corrupts the install.Root cause
In
rebuild.js,#runScriptsdestructuresisStoreLinkfromnode.target(the store entry) to decide whether to skip a node. ButisStoreLinkis a property of the link node itself (node), not its target. Store entries don't haveisStoreLink, so it's alwaysundefinedand the guard never triggers. Both the store entry and the store link run scripts against the same directory in parallel.Changes
rebuild.js#runScriptsto usenode.isLink && node.target?.isInStoreinstead of readingisStoreLinkfromnode.target. This correctly skips store links (symlinks pointing to store entries) while still allowing workspace links and store entries themselves to run scripts.References
Fixes #9012