Skip to content

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
npm:latestfrom
brilliantkid87:fix-9911-place-dep-null-virtualroot
Open

fix(arborist): don't crash when a peer dep is evicted from its virtual root (#9911)#9933
brilliantkid87 wants to merge 1 commit into
npm:latestfrom
brilliantkid87:fix-9911-place-dep-null-virtualroot

Conversation

@brilliantkid87

Copy link
Copy Markdown

npm install -g @deepseek-harness-tui/dsh-tui@0.9.0 crashes with TypeError: Cannot read properties of null (reading 'children') at place-dep.js, thrown from new PlaceDep#buildDepStepArborist.buildIdealTreeArborist.reify. The package has 26 peer deps spanning prerelease lines. The expected result is a completed install (conflicting peers placed deeper) or a normal ERESOLVE error with --force/--legacy-peer-deps guidance — 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 — the canReplace path in #loadPeerSet — which detaches the node the earlier task still holds (its parent becomes null). When that earlier task's PlaceDep is built, this.dep.parent (the virtual root) is null, and the peer-placement loop dereferences virtualRoot.children, crashing.

The fix. In place-dep.js, guard the peer-placement loop with if (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) in test/arborist/build-ideal-tree.js (global-install mock-registry fixture). Without the guard it fails with the exact original crash; with it, it passes. Full test/arborist/build-ideal-tree.js suite passes (704/704), and test/place-dep.js, test/can-place-dep.js, test/peer-entry-sets.js all pass.

References

Fixes #9911

@brilliantkid87
brilliantkid87 requested review from a team as code owners August 29, 2026 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] npm install -g crashes: Cannot read properties of null (reading 'children') when a peer set resolves across multiple prerelease lines

1 participant