Skip to content

fix: Prevent pnpm overrides from corrupting resolved peer-dep variants#11844

Open
frankeld wants to merge 1 commit intovercel:mainfrom
frankeld:main
Open

fix: Prevent pnpm overrides from corrupting resolved peer-dep variants#11844
frankeld wants to merge 1 commit intovercel:mainfrom
frankeld:main

Conversation

@frankeld
Copy link

Description

When a pnpm lockfile has overrides (e.g. foo: ~1.0.0), turbo prune can produce a broken lockfile that's missing snapshot entries for packages with multiple peer-dependency variants. This happens because apply_overrides corrupts already-resolved version strings like 1.0.0(peer-a@1.0.0)(peer-b@2.0.0) by replacing them with the semver range from the override.

This fix makes resolve_specifier prefer the original specifier when it already matches a snapshot, so overrides only kick in when the specifier doesn't already resolve to a known package.

These issues are reoccurring for many different users. See ongoing bug reports on this closed issue: #3382 (comment)

Here's a repository with a "real" minimal reproduction: https://github.com/frankeld/turbo-prune-repro

Testing Instructions

New unit tests in crates/turborepo-lockfiles/src/pnpm/data.rs:

cargo test -p turborepo-lockfiles test_override_does_not_break_transitive_peer_variant

This test sets up a v9 lockfile with an override (foo: ~1.0.0) and two peer-dep variants of foo, then verifies that:

  • resolve_package still resolves the transitive variant (foo@1.0.0(peer-a@1.0.0)(peer-b@2.0.0))
  • The transitive closure includes both variants and middleware

@frankeld frankeld requested a review from a team as a code owner February 13, 2026 20:26
@frankeld frankeld requested review from tknickman and removed request for a team February 13, 2026 20:26
@vercel
Copy link
Contributor

vercel bot commented Feb 13, 2026

@frankeld is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant