Replies: 2 comments
|
This is a change I will be making in Turborepo 3.0. |
0 replies
This comment was marked as spam.
This comment was marked as spam.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
The Node.js runtime version is not part of turbo's cache hash. This makes CI matrices that run the same tasks across multiple Node versions largely pointless, and can cause a race when matrix legs run in parallel.
What turbo hashes today
turbo folds only the root
package.jsonenginesfield into the global hash:crates/turborepo-task-hash/src/global_hash.rs→engines = root_package.package_json.engines(), which is passed intoGlobalHashable.crates/turborepo-repository/src/package_json.rs→engines()just reads the literal"engines"object (string values) from the rootpackage.json.The actual running
nodebinary version (process.version,node -v, the version selected by nvm /setup-node/ a Docker base image) is never read into the hash.Why this is a problem
Consider a typical CI matrix:
With
enginesunchanged (or absent), all three legs compute an identical global hash. So:Expected behavior
Running the same task under a different Node.js runtime should produce a different cache key, since build output and test results can legitimately differ by runtime.
Proposal
Either:
Workaround, and why the obvious one does not work
The only workaround that actually distinguishes matrix legs is to feed the real runtime version into
globalEnv, e.g."globalEnv": ["NODE_VERSION"], and export the true version in each leg (e.g.echo "NODE_VERSION=$(node -v)" >> "$GITHUB_ENV").Note that adding
.nvmrc/.node-versiontoglobalDependenciesdoes not work for the matrix case: that file pins a single version for the repo, so its contents are identical across all matrix legs (the matrix installs a version other than the pinned one). A static file that never changes between legs cannot differentiate their cache keys.Filing as an idea per the issue-template routing. Happy to provide a minimal reproduction if it would help move this forward.
All reactions