Repository navigation
fix(arborist): skip moving back nodes that were never retired - #10194
Open
tillschweneker wants to merge 1 commit into
Open
tillschweneker wants to merge 1 commit into
tillschweneker wants to merge 1 commit into
Conversation
When a changed node and an unchanged node link the same bin, retiring the changed node moves that bin aside. Loading a changed bundler (or a shrinkwrap) re-diffs the trees; the unchanged node's bin is now missing, so it becomes a CHANGE that was never retired. moveBackRetiredUnchanged then resolves its children against an undefined retire folder and throws ERR_INVALID_ARG_TYPE, which the rollback masks with the same error on the "from" argument. The node was never moved, so its unchanged children are still in place: skip it instead of throwing. Fixes: npm#4907 Fixes: npm#4448 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 tasks done
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.
This implements fix 1 from @amurashincertinia's root-cause analysis in #4907, with a regression test for the
bundleDependenciespath they predicted. Their other suggestions aren't included: never letting a rollback replace the original error, refreshing the retire map after each re-diff, and handlingENOTEMPTYin[_renamePath]. Those are separate improvements, and fix 1 already keeps an unretired folder out of the rollback.npm installcrashes withERR_INVALID_ARG_TYPE: The "from" argument must be of type string. Received undefinedwhen three things meet in one install:sanityand@sanity/cliboth install.bin/sanity.bundleDependencies(or a shrinkwrap) makes reify re-diff the trees.getActionnow finds the unchanged node's bin missing and marks itCHANGE, but it was never retired.[moveBackRetiredUnchanged]then looks up an undefined retire folder andresolve()throws.[rollbackMoveBackRetiredUnchanged]throws the same error onrelative(), which hides the first one. The debug-only check above it already called this case "should be impossible".That node was never moved, so its unchanged children are still in place. This PR skips it instead of throwing.
The regression test packs four tiny local tarballs (two packages sharing a bin, one bundler and one nested dep), installs, then updates. Without the fix it fails with the error users report. With the fix, the arborist suite passes at 100% coverage.
I also checked the patch against a real project of about 2,800 packages that hit this nightly. The resulting
node_modules, with every package version and every.binlink, is identical to a freshnpm ciof the same lockfile.References
Fixes #4907
Fixes #4448
🤖 Generated with Claude Code