turbo icon indicating copy to clipboard operation
turbo copied to clipboard

feat(turborepo): pass through arguments only for root tasks

Open HelloWorld017 opened this issue 1 year ago • 7 comments

Description

In the document, it says that cli arguments are not passed through task dependencies.

Note that these additional arguments will not be passed to any additional tasks that are run due to dependencies from the pipeline configuration.

But when I actually run a task with additional arguments (e.g. turbo run dev -- --env=stage) the arguments (e.g. --env=stage) are passed through all the dependencies, and their caches are missed.

Related Issues: #1744 #5743

Fixes

Only pass the additional cli arguments to the root tasks. (= tasks which are not required by other tasks)

Testing Instructions

  1. Open the design-system example.
  2. In docs, run turbo run build --summarize -- --disable-telemetry.
  3. Ensure that --disable-telemetry is only passed in @repo/docs#build, not @acme/ui#build
  4. In docs, run turbo run build --summarize -- --test
  5. Ensure that @acme/ui#build is cached.

HelloWorld017 avatar May 04 '24 16:05 HelloWorld017

The latest updates on your projects. Learn more about Vercel for Git ↗︎

7 Ignored Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview May 5, 2024 7:52am
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview May 5, 2024 7:52am
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview May 5, 2024 7:52am
examples-native-web ⬜️ Ignored (Inspect) Visit Preview May 5, 2024 7:52am
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview May 5, 2024 7:52am
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview May 5, 2024 7:52am
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview May 5, 2024 7:52am

vercel[bot] avatar May 04 '24 16:05 vercel[bot]

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

A member of the Team first needs to authorize it.

vercel[bot] avatar May 04 '24 16:05 vercel[bot]

This would be great!

marisuxma avatar May 23 '24 07:05 marisuxma

@jaredpalmer

marisuxma avatar May 23 '24 07:05 marisuxma

Hey, sorry about this but that behavior must have been misdocumented. The behavior you're seeing is the one we intend to have and the docs reflect that today.

It's possible that I could bring up this behavior with the team and see if it could be a configuration or flag. Does that interest the both of you?

(Sidebar: @marisuxma, Jared doesn't work on this project anymore.) 😄

anthonyshew avatar Jun 15 '24 23:06 anthonyshew

the docs reflect that today.

Actually the document does not describe the exact behaviour. Here's the summarized current behaviour.

  1. The arguments are passed to all tasks.
  2. The arguments are passed to all tasks, with same command name[^1]
  3. The arguments are passed to only root tasks

[^1]: e.g. for test --coverage with ^build and ^test deps, the --coverage flag is only passed through the ^test deps.

1 2 3 Reference
Documentation
Cache Key task_hash.rs#L390
--summarize json summary/task_factory.rs#L162
Actual Running Task task_graph/visitor.rs#L637 opts.rs#L156
This PR

It's possible that I could bring up this behavior with the team and see if it could be a configuration or flag

Currently the Actual task running is different with cache key, which can create falsy cache, so I think they should be fixed. And if all flags are passed through, ^build dependencies might cause turbo run test --coverage passing --coverage to build and turbo run dev --host passing --host to build.

Conclusion

So, if the 3 behavior (which is suggested by this PR) is not the preferred solution, I suggest making doucment / cache key / --summarize to reflect the current behavior (which is 2). And that can be represented like:

1 2 3 Reference
Documentation
Cache Key
--summarize json
Actual Running Task

If you want, I can open another PR, to do that.

HelloWorld017 avatar Jun 16 '24 09:06 HelloWorld017

@anthonyshew (as a gentle reminder) would you check the comment I wrote?

HelloWorld017 avatar Aug 30 '24 05:08 HelloWorld017

@HelloWorld017 If you want to prevent unexpected additional parameters, This may help you.

https://github.com/vercel/turborepo/issues/1744#issuecomment-2597901349

hchangjae avatar Jan 17 '25 10:01 hchangjae

Closing in favor of #10167. This behavior change would require a major version bump.

chris-olszewski avatar Mar 14 '25 17:03 chris-olszewski