Skip to content

feat: add async-service, a suite that awaits through every layer - #3

Draft
hi-ogawa wants to merge 2 commits into
vitest-dev:mainfrom
hi-ogawa:async-service
Draft

hi-ogawa wants to merge 2 commits into
vitest-dev:mainfrom
hi-ogawa:async-service

Conversation

@hi-ogawa

@hi-ogawa hi-ogawa commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

No app awaits in its tests. cpu-bound and node-backend are fully synchronous, so a change that costs something per promise in the test worker, such as AsyncLocalStorage on Node 22, doesn't show up in any of them.

This adds async-service: node-backend's shape (repos, domain services, CRUD tests) with every layer async. A driver checks out a pooled connection, repos query through it, and services validate, write an audit row and fan out with Promise.all. It has 64 test files of 3 tests each, and each test awaits tens of thousands of promises, so a default run spends most of its time in the tests rather than in startup. It has no dependencies, so module loading stays small. The default matrix runs forks and threads with isolate on and off.

vitest main vs vitest-dev/vitest#11887

Setup:

  • Two local builds: vitest main at 71ad4dfa1 and the #11887 head at 5726e0a6e, each linked into the app's node_modules/vitest.
  • Apple M4 Pro (12 cores), Node 22.18.0 and 24.16.0. Default config: forks, isolate: true, default maxWorkers.
  • Wall time of vitest run, median of 8 runs after one untimed priming run, with the four Node and build cells interleaved.
app Node main #11887 Δ
cpu-bound 22 1.69s 1.61s ~0
cpu-bound 24 1.60s 1.63s ~0
node-backend 22 1.15s 1.14s ~0
node-backend 24 0.97s 0.96s ~0
async-service 22 3.45s 4.76s +38%
async-service 24 3.00s 3.08s ~0

The sync apps don't move on either Node version. On Node 22, async-service is 38% slower with #11887, and the runs don't overlap (3.32–3.61 s vs 4.64–5.03 s). On Node 24 it's within noise (2.89–3.20 s vs 2.74–3.29 s). That matches how the two versions implement AsyncLocalStorage: Node 22 runs promise hooks on every promise, while Node 24 builds it on AsyncContextFrame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant