fix: Fix non-deterministic hashOfExternalDependencies with Bun lockfiles - #12279
Merged
Conversation
The resolve cache in all_transitive_closures() omitted workspace_path from cache keys for transitive dependencies, assuming resolution is workspace-independent. This is false for Bun lockfiles where workspace-scoped resolution produces different results per workspace. Combined with non-deterministic parallel iteration order, this caused hashOfExternalDependencies to vary across runs. Always include workspace_path in resolve cache keys so each workspace gets correctly isolated cache entries. Closes #12252
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
anthonyshew
enabled auto-merge (squash)
March 13, 2026 12:53
1 task
github-actions Bot
added a commit
that referenced
this pull request
Mar 13, 2026
## Release v2.8.17-canary.15 Versioned docs: https://v2-8-17-canary-15.turborepo.dev ### Changes - release(turborepo): 2.8.17-canary.14 (#12278) (`85719d6`) - fix: Fix non-deterministic hashOfExternalDependencies with Bun lockfiles (#12279) (`bb1e1da`) Co-authored-by: Turbobot <turbobot@vercel.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.
Summary
Fixes #12252
all_transitive_closures()omittedworkspace_pathfrom cache keys, assuming resolution is workspace-independent. This is false for Bun lockfiles where workspace-scoped resolution (workspace_name/package_nameentries) can produce different results per workspace.HashMap::into_par_iter(), whichever workspace populated the cache first would poison the results for other workspaces — causinghashOfExternalDependenciesto flip between values across runs.How it works
Always include
workspace_pathin the resolve cache key so each workspace gets correctly isolated cache entries. This is a no-op for pnpm/npm/yarn (where transitive deps are already fully resolved keys), but critical for Bun whereall_dependencies()can return raw semver ranges that require workspace-scoped resolution.How to verify
The new test
test_all_transitive_closures_deterministic_with_workspace_scoped_packagesconstructs a Bun lockfile where two workspaces resolve the same transitive dependency to different versions via workspace-scoped entries, then runsall_transitive_closures50 times asserting consistent, correct results. This test would fail without the fix due to cache poisoning from the parallel workspace processing.A check-lockfiles fixture from the reproduction repo is also included at
lockfile-tests/fixtures/bun-v1-issue-12252/.