turbo
turbo copied to clipboard
[turborepo] Scripts execution order broken
What version of Turborepo are you using?
1.6.2
What package manager are you using / does the bug impact?
npm, Yarn v1
What operating system are you using?
Mac
Describe the Bug
Script doesn't run when dependent script result is changed and replayed.
Spent hours to understand why the result of script execution is unpredictable! This literally renders the task dependency graph useless.
Expected Behavior
Script must run when dependent script result is changed and replayed.
To Reproduce
With repro project do:
- Assume content of file
packages/lib-a/src/index.tsin stateS1 - Run
yarn run deploy - Change content of file
packages/lib-a/src/index.tsto another stateS2 - Run
yarn run deploy - Change content of file
packages/lib-a/src/index.tsto stateS1 - Run
yarn run deploy - Change content of file
packages/lib-a/src/index.tsto stateS2 - Run
yarn run deploy - Check content of file
deploy/a/lib/index.js. Must be in stateS2
Reproduction Repo
https://github.com/arthurgubaidullin/turborepo-bug-repro-scripts-execution-order-broken
Thanks for the repro. Can you specify at which step in the repro steps the issue occurs and what the expected behavior is? Also, just to make sure, you're toggling the contents of lib-a between two versions, correct?
@chris-olszewski The problem occurs at step 8. I expect the depoy script to run if the build script's output has changed, even if it's replayed.
Yes, I switch between versions in repro. But in fact it may have more versions.

I think Turbo is behaving as expected. Since the deploy directory isn't in the outputs section for the deploy task, Turbo doesn't know that it should update those files from cache on a hit.
@chris-olszewski How can output of the deploy command affect the work of the build command?
I want to build script execution chains. First, the build script must be executed, then the deploy.
The build script puts the output in the lib. Deploy script takes input from lib.
Why, if there is an old version of the build in the cache, does the deploy script not run at all?
This use case is broken. For understanding.
How can output of the deploy command affect the work of the build command?
It's not affecting the result of the build command. From what I've observed in your repro build is correctly producing the artifacts in lib. The issue comes when deploy, seeing that it's inputs are in the cache, is a cache hit and replays the logs, but doesn't update the content of deploy since Turbo doesn't know that there are outputs that need updating.
This use case is broken
The case works, but using the task name deploy might be bad due to people generally not wanting that task to be cached e.g. rolling back a deploy