vercel / turborepo

Build system optimized for JavaScript and TypeScript, written in Rust
https://turbo.build/repo/docs
MIT License
26.3k stars 1.82k forks source link

[WEB-880] [turborepo] Persistent task concurrency validation not taking into account whether package has the script defined #4291

Open shawnmcknight opened 1 year ago

shawnmcknight commented 1 year ago

What version of Turborepo are you using?

1.8.5

What package manager are you using / does the bug impact?

pnpm

What operating system are you using?

Windows

Describe the Bug

I believe this is related to #4205. If you have a task which is designated as persistent, it will validate that concurrency limits are not breached. However, the calculation of how many parallel tasks will be executed is not taking into account that not every package in the defined filter has the script defined.

For instance, I have a turbo task dev which is flagged as persistent. This is launched as: turbo run dev --filter=@scope/app.*...

The count of tasks gets indicated as 24 in my example, which breaches the concurrency limit of 10. The count of 24 is the total count of packages matching the filter and all of its dependencies. However, only 4 of the packages in the filter's scope actually have dev scripts defined. This same issue does not occur if a filter is not defined. Effectively, the validation of concurrency limits should verify if a package in the filter's scope actually has the script defined before erroring. Packages without the script defined should not be counted in the validation.

Expected Behavior

Since in my example only 4 dev scripts exist within the filter's scope, the turbo task should be permitted to run as it will not breach concurrency limits.

To Reproduce

In this example, only package a will run a script because it's the only one with the script defined. However, the count will be detected as exceeding the limit of 1 parallel task because it's using a count of all packages in scope and not the number of scripts which will be executed.

Reproduction Repo

No response

WEB-880

TURBO-1141

shawnmcknight commented 1 year ago

Actually, upon further testing, the filter isn't a necessary step here. If I have a dev script defined in a small number of workspace packages, but have more than 10 total workspace packages, I will get the error without supplying a filter as well.

rottbers commented 1 year ago

Running into the same with npm. In my case only 4 out of 10 workspaces have the persistent script (dev) present in their package.json but yet all 10 workspaces seems to be targeted resulting in the following error:

ERROR run failed: error preparing engine: Invalid persistent task configuration:
You have 10 persistent tasks but `turbo` is configured for concurrency of 10. Set --concurrency to at least 11
connorjs commented 1 year ago

I just hit this too. Current workaround: (1) Run any dependsOn steps manually (e.g. build) and (2) use npm run directly.

npm run dev --workspaces --if-present

Swap dev for the appropriate run script name.

connorjs commented 1 year ago

Better workaround: Downgrade turbo to 1.8.3. The bug started appearing in 1.8.4. (Assuming you do not need 1.8.4+ features.)

Also consider disabling the update notifier in this case? https://turbo.build/repo/docs/reference/command-line-reference#--no-update-notifier.

unindented commented 1 year ago

Experiencing the same issue on macOS, with 1.8.5-1.8.8.

hsuabina commented 1 year ago

+1

We had to disable the persistent flag on the root dev script because of this issue.

trappar commented 1 year ago

I'm also seeing issues as a result of this on 1.8.8 and it's causing confusion for people onboarding onto a monorepo project I recently built.

mehulkar commented 1 year ago

Hey all, thanks for reporting, we'll fix this up shortly!

pencilcheck commented 1 year ago

Better workaround: Downgrade turbo to 1.8.3. The bug started appearing in 1.8.4. (Assuming you do not need 1.8.4+ features.)

Also consider disabling the update notifier in this case? https://turbo.build/repo/docs/reference/command-line-reference#--no-update-notifier.

still having this issue tonight, reverting back to 1.8.3 seems to fix this issue.

ph55 commented 1 year ago

dev turbo dev --no-cache --continue

ERROR run failed: error preparing engine: Invalid persistent task configuration: You have 10 persistent tasks but turbo is configured for concurrency of 10. Set --concurrency to at least 11

hBulldozer commented 1 year ago

Better workaround: Downgrade turbo to 1.8.3. The bug started appearing in 1.8.4. (Assuming you do not need 1.8.4+ features.) Also consider disabling the update notifier in this case? https://turbo.build/repo/docs/reference/command-line-reference#--no-update-notifier.

still having this issue tonight, reverting back to 1.8.3 seems to fix this issue.

Same here... Cant update

nedis-code commented 1 year ago

same issue

yarn dev
yarn run v1.22.19
$ turbo dev --no-cache  --continue
 ERROR  run failed: error preparing engine: Invalid persistent task configuration:
You have 10 persistent tasks but `turbo` is configured for concurrency of 10. Set --concurrency to at least 11
Turbo error: error preparing engine: Invalid persistent task configuration:
You have 10 persistent tasks but `turbo` is configured for concurrency of 10. Set --concurrency to at least 11
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Tobjoern commented 1 year ago

I just bumped into this issue at v1.9.3.

alikleitcr7 commented 1 year ago

Well, do what they say until resolved:

 "dev": "turbo run dev --concurrency 11" 

I guess it can be increased based on the number of projects in the workspace.

mehulkar commented 1 year ago

Hey all, I'm sorry I wasn't able to get to this yet. Taking pat leave for some time, but I've passed this on to the team. I've let the team know about this open issue, but if anyone is able to make a PR even if just to revert #4205, it may be worth merging until we can find a real fix. @nathanhammond is also on leave for some time, which is why you haven't heard from him in a while.

geovanesantana commented 1 year ago

I just got this issue in v1.9.3

yarn run v1.22.19
$ turbo dev --no-cache  --continue
 ERROR  run failed: error preparing engine: Invalid persistent task configuration:
You have 10 persistent tasks but `turbo` is configured for concurrency of 10. Set --concurrency to at least 11
Turbo error: error preparing engine: Invalid persistent task configuration:
You have 10 persistent tasks but `turbo` is configured for concurrency of 10. Set --concurrency to at least 11
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
hongfaqiu commented 1 year ago

Same issue in v1.10.12:

pnpm dev

> turbo dev --filter=!doc --no-cache  --continue

 ERROR  run failed: error preparing engine: Invalid persistent task configuration:
You have 13 persistent tasks but `turbo` is configured for concurrency of 13. Set --concurrency to at least 14
Turbo error: error preparing engine: Invalid persistent task configuration:
You have 13 persistent tasks but `turbo` is configured for concurrency of 13. Set --concurrency to at least 14
 ELIFECYCLE  Command failed with exit code 1.

When I set the concurrency to 14, the command takes effect:

"dev": "turbo dev --filter=!doc --concurrency 14"
Nilegfx commented 1 year ago

I got the same error with 1.10.14.

jpreynat commented 1 year ago

Same here on 1.10.3 and after trying to upgrade to 1.10.15 hoping it'd been fixed. This is really painful... 😓

mehulkar commented 1 year ago

Just an update, we talked about this at the team meeting and we want to fix it. PRs welcome

ilyagru commented 1 year ago

Hey, any updates on this one? I have 10+ packages overall but the "dev" script is defined in one of them only. I guess it shouldn't fail in this case.

"turbo": "^1.10.16"

levino commented 11 months ago

Is it possible to set the concurrency in turbo.json globally? To say 1000 or something? Kinda annoying to have to tell all developers to run turbo [...] --concurrency 1000.

arlyon commented 10 months ago

The linked PR fixes the issue. Should be released in the next minor. Thanks for the patience as we were working towards the rust port :heart:

thebjorn commented 5 months ago

I'm seeing this in 1.13.3...

 srv/lib/tilly❱ turbo dev                                                                           
  × invalid task configuration

Error:   × You have 11 persistent tasks but `turbo` is configured for concurrency of 10. Set --concurrency to at least 12

srv/lib/tilly❱ turbo --version                                                                                                                         
1.13.3
luskin commented 4 months ago

Seeing this ins 2.0.3 still.

najwer23 commented 2 months ago

"turbo": "^2.1.0", still

Ahsan-Ullah1871 commented 1 month ago

still i am facing this issue

arlyon commented 1 day ago

I can repro, so it seems like we have a regression. Reopening.