fix: list command should not fail with an OOM error#10586
Merged
Conversation
This was referenced Feb 10, 2026
Closed
Closed
7 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses out-of-memory failures in pnpm list / pnpm why on large dependency graphs by ensuring each package subtree is expanded at most once and subsequent occurrences are rendered as deduped nodes (with a hidden-deps count), including in JSON output.
Changes:
- Replaces recursive tree building with a two-phase approach: build a BFS dependency graph, then materialize a deduplicated tree using a shared cache.
- Adds dedupe indicators to tree and JSON renderers (
deduped,dedupedDependenciesCount) so users can see when subtrees are elided. - Adds/updates tests and fixtures (including a large lockfile fixture) to prevent regressions and validate circular/search/dedupe behavior.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| reviewing/list/test/manyDeps.ts | Adds a regression test to ensure list can handle a large dependency graph without OOM. |
| reviewing/list/test/fixtures/many-deps/package.json | Fixture project manifest for the large dependency graph test. |
| reviewing/list/test/fixtures/many-deps/.npmrc | Fixture registry config for the large dependency graph test. |
| reviewing/list/test/fixtures/many-deps/pnpm-lock.yaml | Large lockfile fixture used to reproduce the prior OOM scenario. |
| reviewing/list/src/renderTree.ts | Adds deduped (N deps hidden) rendering in tree output. |
| reviewing/list/src/renderJson.ts | Adds deduped / dedupedDependenciesCount to JSON output schema. |
| reviewing/dependencies-hierarchy/test/getTree.test.ts | Updates tests to use the new graph+cache approach and adds coverage for dedupe/search/circular interactions. |
| reviewing/dependencies-hierarchy/test/circularTree.json | Updates expected circular fixture output to match dedupe behavior. |
| reviewing/dependencies-hierarchy/src/getTree.ts | Implements cached tree materialization + dedupe metadata and a post-pass to mark circular back-edges. |
| reviewing/dependencies-hierarchy/src/buildDependencyGraph.ts | Introduces BFS graph construction used by the new tree materialization logic. |
| reviewing/dependencies-hierarchy/src/buildDependenciesHierarchy.ts | Switches hierarchy building to construct one shared graph+cache per project for reuse across top-level deps/fields. |
| reviewing/dependencies-hierarchy/src/TreeNodeId.ts | Adds a default case to throw on unknown TreeNodeId types during serialization. |
| reviewing/dependencies-hierarchy/src/PackageNode.ts | Extends the node type with dedupe metadata fields. |
| reviewing/dependencies-hierarchy/src/DependenciesCache.ts | Removes the old dependencies cache implementation replaced by graph+materialization cache. |
| cspell.json | Adds a trailing newline (format-only change). |
| .changeset/fix-list-oom.md | Adds a changeset entry describing the OOM fix and new dedupe output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 16 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
zkochan
added a commit
that referenced
this pull request
Feb 10, 2026
zkochan
added a commit
to teambit/bit
that referenced
this pull request
Feb 17, 2026
`bit why` now shows a reverse dependency tree. The searched package appears at the root with its dependents as branches, walking back to workspace components. This replaces the previous forward-tree output which was noisy and hard to read for deeply nested dependencies. Also with the complete rewrite of the dependency tree builder we have fixed the out-of-memory errors that were frequent with the why command. The command also became a lot faster. ## Proposed Changes Related PRs: - pnpm/pnpm#10582 - pnpm/pnpm#10586 - pnpm/pnpm#10615 - pnpm/pnpm#10616 - pnpm/pnpm#10627 - pnpm/pnpm#10629 - pnpm/pnpm#10596 --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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.
Each package's full subtree is expanded exactly once. Subsequent occurrences show
deduped (N deps hidden)so the user knows the subtree exists elsewhere in the output. In JSON output, the same information appears as"deduped": trueand"dedupedDependenciesCount": N.Example output after the fix: https://gist.github.com/zkochan/ec071623b49c16e50f2ad11d16509c8f
Before the fix: https://gist.github.com/zkochan/49a6b4886a815350e458edbd4711772d
close #8731