vercel / turborepo

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

[turborepo] concurrency limit breaks when a task errors out #2887

Closed AlexAegis closed 2 weeks ago

AlexAegis commented 1 year ago

What version of Turborepo are you using?

1.6.3

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

pnpm

What operating system are you using?

Linux

Describe the Bug

Turborepo's concurrency setting breaks once an error is observed. If one of the executed tasks returns with 1 turbo will execute every remaining task at once regardless of the value of --concurrency

I also tested it with 1.5.*, the issue was present

I'm actually on Windows/WSL

Example, running turbo run test --concurrency 2

# ... before this point only 2 tasks were being executed at any given time
@alexaegis/advent-of-code-2021-21:test: ERROR: command finished with error: command (/home/alex/git/@alexaegis/advent-of-code/solutions/typescript/2021/21) pnpm run test exited (1)
# ... after it, you can see this is a lot more than 2
@alexaegis/advent-of-code-2016-02:test: cache miss, executing 639047a84ccf8023
@alexaegis/advent-of-code-2015-04:test: cache miss, executing 3280086c58a105dc
@alexaegis/advent-of-code-2020-05:test: cache miss, executing d6b6532f5c460697
@alexaegis/advent-of-code-2019-01:test: cache miss, executing 868b0f4fb2ba65fb
@alexaegis/advent-of-code-2018-15:test: cache miss, executing 8509e9399fb7ebd1
@alexaegis/advent-of-code-2018-03:test: cache miss, executing 05b14ceee3ab2c21
@alexaegis/advent-of-code-2018-12:test: cache miss, executing efa0d9a9a2918f24
@alexaegis/advent-of-code-2021-16:test: cache miss, executing d55648999d80d74f
@alexaegis/advent-of-code-2021-13:test: cache miss, executing 1ec18a1c68f5c9c8
@alexaegis/advent-of-code-2019-12:test: cache miss, executing bdd7390eb750ec0c
@alexaegis/advent-of-code-2020-21:test: cache miss, executing a1770238ff83c7bf
@alexaegis/advent-of-code-2020-16:test: cache miss, executing 37698a3f9f9f5d7f
@alexaegis/advent-of-code-2020-19:test: cache miss, executing 01518afe953f3653
@alexaegis/advent-of-code-2021-01:test: cache miss, executing ed7f78aed374eefa
@alexaegis/advent-of-code-2018-01:test: cache miss, executing 35d5464f25a1d456
@alexaegis/advent-of-code-2018-07:test: cache miss, executing ba5f1acdbb871f36
@alexaegis/advent-of-code-2018-09:test: cache miss, executing f81cf430f725eda6
@alexaegis/advent-of-code-2019-23:test: cache miss, executing c8a209c062bc69b6

Expected Behavior

When running a set of tasks, the number of concurrently executed tasks should never raise above the limit set by the user.

To Reproduce

I linked a branch where some tests are intentionally broken, the repo uses pnpm, run pnpm install and pnpm test for a quick reproduction

At workspace package json:

        "lint": "turbo run test --concurrency 2",

At each package:

        "test": "vitest --passWithNoTests --coverage --run",

This isn't specific to tests, the same thing happened with lints, tsc checks and prettier.

Reproduction Repo

https://github.com/AlexAegis/advent-of-code/tree/repro/turbo-concurrency-bug

chris-olszewski commented 2 weeks ago

Tested in latest canary and this was fixed in the Rust port.