Skip to content

fix(runner): limit concurrency per task branch in addition to per leaf callbacks#10179

Merged
sheremet-va merged 6 commits intovitest-dev:mainfrom
hi-ogawa:fix-runner-limit-concurrency-per-task-branch-in-addition-to-leaf
Apr 28, 2026
Merged

fix(runner): limit concurrency per task branch in addition to per leaf callbacks#10179
sheremet-va merged 6 commits intovitest-dev:mainfrom
hi-ogawa:fix-runner-limit-concurrency-per-task-branch-in-addition-to-leaf

Conversation

@hi-ogawa
Copy link
Copy Markdown
Collaborator

@hi-ogawa hi-ogawa commented Apr 24, 2026

Description

In #9653, we've changed concurrency limit from per-runTest level to per-indivisual user callbacks. While it sounds clean in principle, it lost runTest level serialization between siblings.

For example, with the following tests and maxConcurrent = 1:

beforeEach(async ({ task }) => {
  console.log("!> beforeEach", task.name)
  await sleep(10)
  console.log("!> beforeEach", task.name)
})

afterEach(async ({ task }) => {
  console.log("!> afterEach", task.name)
})

test.concurrent.for(["a", "b"])("%s", (_, { task }) => {
  console.log("!> test", task.name)
  await sleep(10)
  console.log("!< test", task.name)
})

before #9653:

!> beforeEach a
!< beforeEach a
!> test a
!< test a
!> afterEach a
!< afterEach a
!> beforeEach b
!< beforeEach b
!> test b
!< test b
!> afterEach b
!< afterEach b

and current main after #9653:

(Notably this still guarantees each callback level in-out concurrency limit but not beforeEach -> test -> afterEach lifecycle level in-out)

!> beforeEach a
!< beforeEach a
!> beforeEach b
!< beforeEach b
!> test a
!< test a
!> test b
!< test b
!> afterEach a
!< afterEach a
!> afterEach b
!< afterEach b

This PR brings back siblings serialization guarantee by introducing independent concurrency limit at each task branch. This now also guarantees sibling suite hooks concurrency guarantee which has never existed even before #9653.

TODO

  • summary
  • test

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 24, 2026

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 9d9e78d
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/69eff679f81d8e0008ae3bd8
😎 Deploy Preview https://deploy-preview-10179--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@dbousamra
Copy link
Copy Markdown

@hi-ogawa Awesome! How can i test this pre release?

@hi-ogawa hi-ogawa changed the title fix(runner): limit concurrency per task branch in addition to per leaf function fix(runner): limit concurrency per task branch in addition to per leaf callbacks Apr 24, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 24, 2026

@vitest/browser

npm i https://pkg.pr.new/@vitest/browser@10179

@vitest/browser-playwright

npm i https://pkg.pr.new/@vitest/browser-playwright@10179

@vitest/browser-preview

npm i https://pkg.pr.new/@vitest/browser-preview@10179

@vitest/browser-webdriverio

npm i https://pkg.pr.new/@vitest/browser-webdriverio@10179

@vitest/coverage-istanbul

npm i https://pkg.pr.new/@vitest/coverage-istanbul@10179

@vitest/coverage-v8

npm i https://pkg.pr.new/@vitest/coverage-v8@10179

@vitest/expect

npm i https://pkg.pr.new/@vitest/expect@10179

@vitest/mocker

npm i https://pkg.pr.new/@vitest/mocker@10179

@vitest/pretty-format

npm i https://pkg.pr.new/@vitest/pretty-format@10179

@vitest/runner

npm i https://pkg.pr.new/@vitest/runner@10179

@vitest/snapshot

npm i https://pkg.pr.new/@vitest/snapshot@10179

@vitest/spy

npm i https://pkg.pr.new/@vitest/spy@10179

@vitest/ui

npm i https://pkg.pr.new/@vitest/ui@10179

@vitest/utils

npm i https://pkg.pr.new/@vitest/utils@10179

vitest

npm i https://pkg.pr.new/vitest@10179

@vitest/web-worker

npm i https://pkg.pr.new/@vitest/web-worker@10179

commit: 9d9e78d

This comment was marked as low quality.

@hi-ogawa
Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@hi-ogawa hi-ogawa marked this pull request as ready for review April 24, 2026 04:01
@hi-ogawa
Copy link
Copy Markdown
Collaborator Author

@dbousamra Please test it out the package in #10179 (comment).

@hi-ogawa hi-ogawa added this to the 5.0.0 milestone Apr 27, 2026
@hi-ogawa hi-ogawa requested a review from sheremet-va April 28, 2026 00:12
@sheremet-va sheremet-va merged commit 3112abe into vitest-dev:main Apr 28, 2026
15 of 17 checks passed
@hi-ogawa hi-ogawa deleted the fix-runner-limit-concurrency-per-task-branch-in-addition-to-leaf branch April 28, 2026 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

4 participants