Skip to content

fix: list command should not fail with an OOM error#10586

Merged
zkochan merged 19 commits intomainfrom
fix-list-oom
Feb 10, 2026
Merged

fix: list command should not fail with an OOM error#10586
zkochan merged 19 commits intomainfrom
fix-list-oom

Conversation

@zkochan
Copy link
Member

@zkochan zkochan commented Feb 9, 2026

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": true and "dedupedDependenciesCount": N.

Example output after the fix: https://gist.github.com/zkochan/ec071623b49c16e50f2ad11d16509c8f

Before the fix: https://gist.github.com/zkochan/49a6b4886a815350e458edbd4711772d

close #8731

@zkochan zkochan marked this pull request as ready for review February 10, 2026 17:39
Copilot AI review requested due to automatic review settings February 10, 2026 17:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@zkochan zkochan requested a review from a team February 10, 2026 17:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 zkochan merged commit a49b243 into main Feb 10, 2026
13 checks passed
@zkochan zkochan deleted the fix-list-oom branch February 10, 2026 23:38
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>
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.

Fixing the pnpm list command

2 participants