fix(arborist): don't crash when a peer dep is evicted from its virtual root (#9911) - #9933
Open
brilliantkid87 wants to merge 1 commit into
Open
Conversation
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.
npm install -g @deepseek-harness-tui/dsh-tui@0.9.0crashes withTypeError: Cannot read properties of null (reading 'children')atplace-dep.js, thrown fromnew PlaceDep←#buildDepStep←Arborist.buildIdealTree←Arborist.reify. The package has 26 peer deps spanning prerelease lines. The expected result is a completed install (conflicting peers placed deeper) or a normalERESOLVEerror with--force/--legacy-peer-depsguidance — not a crash.Root cause. In a global install, top-level peers are queued as problem edges resolved one at a time. Resolving one peer edge places a peer version (e.g.
agent@2.0.0) into the virtual root; resolving a later edge's peer set then replaces it with a different version (agent@1.0.0) at the same inventory slot — thecanReplacepath in#loadPeerSet— which detaches the node the earlier task still holds (itsparentbecomesnull). When that earlier task'sPlaceDepis built,this.dep.parent(the virtual root) isnull, and the peer-placement loop dereferencesvirtualRoot.children, crashing.The fix. In
place-dep.js, guard the peer-placement loop withif (virtualRoot). When the placed dep has been evicted from its virtual root, there is no sibling peer set left to place here; the placed node's unmet peers are re-resolved when it is processed from the deps queue, so the resolver backs off to the versions the peer set wants instead of crashing.Verification. Added regression test
peer task dep evicted from its virtual root by a later peer edge does not crash (#9911)intest/arborist/build-ideal-tree.js(global-install mock-registry fixture). Without the guard it fails with the exact original crash; with it, it passes. Fulltest/arborist/build-ideal-tree.jssuite passes (704/704), andtest/place-dep.js,test/can-place-dep.js,test/peer-entry-sets.jsall pass.References
Fixes #9911