-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider the used Node.js version for generating hashes (or provide a way to configure runtime hash inputs) #4124
Comments
This issue pops up frequently and I agree that we need to allow users to be able to opt-in to this. We're not sure if that should be a config option (a npm style version string) or a general purpose set of commands like you suggested. We are going to come up with an answer here and I'll update this issue when I have an answer. |
Thanks for considering this, I highly appreciate that! |
Any news on this? We are repeatedly running into issues because of this, and are considering the different options available. Is there a reasonable chance this will be implemented soonish? If not, we'll need to look for alternatives (such writing a wrapper, or switching to Nx). |
We are in the middle of our rust rewrite, and plan on tackling this once things settle. For your case, you could potentially write the node version to a file and have that as an input to the tasks that need it? It's definitely solidly in the 'workaround' category however it will do what you need. |
This bit us in a very unpleasant way. We were midway migrating from Node.js v18 to v20, and the CI kept passing all the checks ✅, but then things started to break post deployment. We've gone through the cycle of upgrade/downgrade several times without noticing that Turbo just uses cached version of the tests from another Node.js version. 😭 |
For reference, this workaround can be implemented like this: |
It is similar to what we did. Just added |
Just an update, we talked about this again in our team meeting and we want to fix this. For now, the script @styfle provided above or using |
### Description While we may consider OS and arch handling as a feature in the future, we don't today. Here, we're documenting how to handle this advanced use case as well as jotting down a proper way of handling Node.js versions. Closes #4124 and #1315 --------- Co-authored-by: Nicholas Yang <nicholas.yang@vercel.com>
Docs have gotten an update for this! Thanks for flagging, folks! |
Which project is this feature idea for?
Turborepo
Describe the feature you'd like to request
At the moment, Turborepo does not consider the used Node.js version as hash input. This can lead to undesirable situations where CI is set up to execute tasks in multiple different Node.js versions, to ensure that the package works in all of them, but then the task is only ever really executed in one of them, because in the others, it's fetched from the cache.
For this reason, the used Node.js version should be considered an input for every generated hash.
Of course, depending on the repo setup, there could be a lot more runtime context that should be considered a hash input (e.g. arch, OS, etc.). For that reason, it would also make sense to allow users to configure arbitrary runtime inputs, similar to
globalEnv
andglobalDependencies
on the global level andenv
on the per-task level.For comparison and reference: Nx already provides this feature: https://nx.dev/concepts/how-caching-works#runtime-hash-inputs
Describe the solution you'd like
Ideally, there is a new optional configuration property
globalRuntime
where users can specify a list of commands to be executed. When turbo is run, those commands are executed and their output is used as an input for all hashes. If the property is not given, Turborepo uses just the commandnode -v
.Example of how the config could look:
Similarly, there is a
runtime
property that can be used in the configuration of tasks to specify the runtime inputs for a specific task.Describe alternatives you've considered
One alternative would be put the result of
node -v
into an environment variable and use that as a has input viaglobalEnv
. However, that is significant effort and some people might simply forget to do it if they executeturbo
directly.We could also write our own small wrapper around
turbo
that does nothing but put runtime information into an environment variable and then call turbo. But that's also quite cumbersome and error prone.In total, this just feels like something Turborepo should take care of.
The text was updated successfully, but these errors were encountered: