Skip to content

Support projects with Node.js step dependencies in vitest plugin#1524

Merged
VaguelySerious merged 11 commits intomainfrom
matchai/vitest-fixes
Mar 26, 2026
Merged

Support projects with Node.js step dependencies in vitest plugin#1524
VaguelySerious merged 11 commits intomainfrom
matchai/vitest-fixes

Conversation

@matchai
Copy link
Copy Markdown
Member

@matchai matchai commented Mar 26, 2026

Three issues prevented @workflow/vitest from working in projects where step functions transitively import Node.js modules (postgres, ioredis, node:path, etc.):

1. Externalized step imports keep TS extensions

externalizeNonSteps emits externalized import paths with raw .ts/.tsx extensions that Node's native ESM loader can't resolve. Rewrite to .js/.mjs/.cjs in the esbuild plugin's onResolve.

2. Stale bundles rediscovered as input

.workflow-vitest/ wasn't in the base builder's ignore list, so stale bundles from previous runs got picked up during file discovery.

3. Eager bundle loading poisons module cache

setupWorkflowTests() eagerly imported both bundles via native import() during vitest setupFiles. This loaded step dependencies into the module cache before vi.mock() could intercept them, breaking mocks in unit tests that never execute workflows. Replaced with memoized lazy handlers that defer import() until first workflow dispatch.

Mock behavior change: with lazy loading, externalized step dependencies now resolve through vite-node after mocks are active. vi.mock() now intercepts them as expected when they used to be ignored.

matchai added 2 commits March 25, 2026 23:14
Five issues prevented @workflow/vitest from working in projects where
step functions transitively import Node.js modules (postgres, ioredis,
node:path, etc.):

1. Externalized step imports kept .ts/.tsx extensions that Node's ESM
   loader can't resolve. Rewrite to .js/.mjs/.cjs in the esbuild plugin.

2. VitestBuilder hardcoded dirs: ['.'] scanning the entire project.
   Production builders scope to framework entry points (e.g. src/app).
   Add dirs option to workflow() and thread it through to the builder.

3. .workflow-vitest/ wasn't in the ignore list, so stale bundles from
   previous runs got rediscovered as input files.

4. workflowTransformPlugin added classId to node_modules serde classes
   via Vite, then the step bundle also registered classId during its
   esbuild build — double defineProperty with configurable:false. Skip
   node_modules packages that only match serde patterns.

5. Eager native import() of step/workflow bundles in setupFiles loaded
   dependencies into the module cache before vi.mock() could intercept
   them. Replace with memoized lazy handlers that defer import() until
   first workflow dispatch.
The .workflow-vitest exclude + lazy bundle loading already prevent the
double classId registration. The broad node_modules skip could break
legitimate serde-only npm packages.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 26, 2026

🦋 Changeset detected

Latest commit: 8d043d7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 16 packages
Name Type
@workflow/builders Patch
@workflow/vitest Patch
@workflow/astro Patch
@workflow/cli Patch
@workflow/nest Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/rollup Patch
@workflow/sveltekit Patch
@workflow/vite Patch
workflow Patch
@workflow/world-testing Patch
@workflow/nuxt Patch
@workflow/ai Patch
@workflow/core Patch
@workflow/web-shared Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview, Comment Mar 26, 2026 10:34pm
example-nextjs-workflow-webpack Ready Ready Preview, Comment Mar 26, 2026 10:34pm
example-workflow Ready Ready Preview, Comment Mar 26, 2026 10:34pm
workbench-astro-workflow Ready Ready Preview, Comment Mar 26, 2026 10:34pm
workbench-express-workflow Ready Ready Preview, Comment Mar 26, 2026 10:34pm
workbench-fastify-workflow Ready Ready Preview, Comment Mar 26, 2026 10:34pm
workbench-hono-workflow Ready Ready Preview, Comment Mar 26, 2026 10:34pm
workbench-nitro-workflow Ready Ready Preview, Comment Mar 26, 2026 10:34pm
workbench-nuxt-workflow Ready Ready Preview, Comment Mar 26, 2026 10:34pm
workbench-sveltekit-workflow Ready Ready Preview, Comment Mar 26, 2026 10:34pm
workbench-vite-workflow Ready Ready Preview, Comment Mar 26, 2026 10:34pm
workflow-swc-playground Ready Ready Preview, Comment Mar 26, 2026 10:34pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
workflow-docs Skipped Skipped Mar 26, 2026 10:34pm

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 26, 2026

🧪 E2E Test Results

Some tests failed

Summary

Passed Failed Skipped Total
✅ ▲ Vercel Production 846 0 67 913
✅ 💻 Local Development 818 0 178 996
✅ 📦 Local Production 818 0 178 996
✅ 🐘 Local Postgres 818 0 178 996
✅ 🪟 Windows 75 0 8 83
❌ 🌍 Community Worlds 130 59 24 213
✅ 📋 Other 207 0 42 249
Total 3712 59 675 4446

❌ Failed Tests

🌍 Community Worlds (59 failed)

mongodb (3 failed):

  • hookWorkflow is not resumable via public webhook endpoint | wrun_01KMP4J3BAJFG3BSB477ZFRFV3
  • webhookWorkflow | wrun_01KMP4JC7XC7K6973SDE52X8JA
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously | wrun_01KMP4TQ48KB1HET6C4ST3ACYB

redis (2 failed):

  • hookWorkflow is not resumable via public webhook endpoint | wrun_01KMP4J3BAJFG3BSB477ZFRFV3
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously | wrun_01KMP4TQ48KB1HET6C4ST3ACYB

turso (54 failed):

  • addTenWorkflow | wrun_01KMP4GX4JHQ59739JJ8AVMXV8
  • addTenWorkflow | wrun_01KMP4GX4JHQ59739JJ8AVMXV8
  • wellKnownAgentWorkflow (.well-known/agent) | wrun_01KMP4J52SNS9FEH0ZGEXY0C70
  • should work with react rendering in step
  • promiseAllWorkflow | wrun_01KMP4H456WSF4WYNMX6FEKMGG
  • promiseRaceWorkflow | wrun_01KMP4H8ZZBJFA5YJ14Y71FNPM
  • promiseAnyWorkflow | wrun_01KMP4HB6Y4D3MF7F6TT1JQ6T3
  • importedStepOnlyWorkflow | wrun_01KMP4JMXVXSBVDHG0NK9NFFKH
  • hookWorkflow | wrun_01KMP4HQJKERBEJSTW19AASKPG
  • hookWorkflow is not resumable via public webhook endpoint | wrun_01KMP4J3BAJFG3BSB477ZFRFV3
  • webhookWorkflow | wrun_01KMP4JC7XC7K6973SDE52X8JA
  • sleepingWorkflow | wrun_01KMP4JJMHPTF3VJC6WN14VWMR
  • parallelSleepWorkflow | wrun_01KMP4K07FP2RB90NV720NGGA9
  • nullByteWorkflow | wrun_01KMP4KDXMPDQF92N019PQN4PF
  • workflowAndStepMetadataWorkflow | wrun_01KMP4KGETT557TC7VW3E5HQKG
  • fetchWorkflow | wrun_01KMP4PCG7PFKV48E3WAK5MEMA
  • promiseRaceStressTestWorkflow | wrun_01KMP4PH5EWKJ010ZTA2K9Z8HV
  • error handling error propagation workflow errors nested function calls preserve message and stack trace
  • error handling error propagation workflow errors cross-file imports preserve message and stack trace
  • error handling error propagation step errors basic step error preserves message and stack trace
  • error handling error propagation step errors cross-file step error preserves message and function names in stack
  • error handling retry behavior regular Error retries until success
  • error handling retry behavior FatalError fails immediately without retries
  • error handling retry behavior RetryableError respects custom retryAfter delay
  • error handling retry behavior maxRetries=0 disables retries
  • error handling catchability FatalError can be caught and detected with FatalError.is()
  • error handling not registered WorkflowNotRegisteredError fails the run when workflow does not exist
  • error handling not registered StepNotRegisteredError fails the step but workflow can catch it
  • error handling not registered StepNotRegisteredError fails the run when not caught in workflow
  • hookCleanupTestWorkflow - hook token reuse after workflow completion | wrun_01KMP4T2MEXE7YB0V7JN0MPPMB
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously | wrun_01KMP4TQ48KB1HET6C4ST3ACYB
  • hookDisposeTestWorkflow - hook token reuse after explicit disposal while workflow still running | wrun_01KMP4VDZYQD7Y6JD470WF4PVD
  • stepFunctionPassingWorkflow - step function references can be passed as arguments (without closure vars) | wrun_01KMP4W23ZBFM6Q6T7N7DCSM4X
  • stepFunctionWithClosureWorkflow - step function with closure variables passed as argument | wrun_01KMP4WDNXJVKW11D2P9D2CY0S
  • closureVariableWorkflow - nested step functions with closure variables | wrun_01KMP4WKC5PR6T9MPWXJY1KHPJ
  • spawnWorkflowFromStepWorkflow - spawning a child workflow using start() inside a step | wrun_01KMP4WNM6RQ4JTJZ76E7VKGCA
  • health check (queue-based) - workflow and step endpoints respond to health check messages
  • pathsAliasWorkflow - TypeScript path aliases resolve correctly | wrun_01KMP4X4T76W39BQ104PA131HQ
  • Calculator.calculate - static workflow method using static step methods from another class | wrun_01KMP4XAJ25CJW8WNW64VEB7MH
  • AllInOneService.processNumber - static workflow method using sibling static step methods | wrun_01KMP4XHB5XM9MFKF5WDH9E901
  • ChainableService.processWithThis - static step methods using this to reference the class | wrun_01KMP4XR275WC13FD0YK3XP0M3
  • thisSerializationWorkflow - step function invoked with .call() and .apply() | wrun_01KMP4XYYP19D86SQ0KC3C6NN1
  • customSerializationWorkflow - custom class serialization with WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZE | wrun_01KMP4Y6EKSTRAT71RXWBGWH1N
  • instanceMethodStepWorkflow - instance methods with "use step" directive | wrun_01KMP4YEM1GB5AVYXHQ625DPEG
  • crossContextSerdeWorkflow - classes defined in step code are deserializable in workflow context | wrun_01KMP4YV2NJ0VF6SFAX7KBXTM9
  • stepFunctionAsStartArgWorkflow - step function reference passed as start() argument | wrun_01KMP4Z2YHK94ZF8P3GN2PERNQ
  • cancelRun - cancelling a running workflow | wrun_01KMP4Z9NA46JY1DK8N5BNJ95D
  • cancelRun via CLI - cancelling a running workflow | wrun_01KMP4ZK1EMCMAF18SXGMDYXC6
  • pages router addTenWorkflow via pages router
  • pages router promiseAllWorkflow via pages router
  • pages router sleepingWorkflow via pages router
  • hookWithSleepWorkflow - hook payloads delivered correctly with concurrent sleep | wrun_01KMP4ZZ9ESQR7QBZ2B5A3CP81
  • sleepInLoopWorkflow - sleep inside loop with steps actually delays each iteration | wrun_01KMP50KYQSB5HFVEDBZT3C5PJ
  • sleepWithSequentialStepsWorkflow - sequential steps work with concurrent sleep (control) | wrun_01KMP50YPNGTCBRBJFJJBRY8QY

Details by Category

✅ ▲ Vercel Production
App Passed Failed Skipped
✅ astro 76 0 7
✅ example 76 0 7
✅ express 76 0 7
✅ fastify 76 0 7
✅ hono 76 0 7
✅ nextjs-turbopack 81 0 2
✅ nextjs-webpack 81 0 2
✅ nitro 76 0 7
✅ nuxt 76 0 7
✅ sveltekit 76 0 7
✅ vite 76 0 7
✅ 💻 Local Development
App Passed Failed Skipped
✅ astro-stable 69 0 14
✅ express-stable 69 0 14
✅ fastify-stable 69 0 14
✅ hono-stable 69 0 14
✅ nextjs-turbopack-canary 58 0 25
✅ nextjs-turbopack-stable 75 0 8
✅ nextjs-webpack-canary 58 0 25
✅ nextjs-webpack-stable 75 0 8
✅ nitro-stable 69 0 14
✅ nuxt-stable 69 0 14
✅ sveltekit-stable 69 0 14
✅ vite-stable 69 0 14
✅ 📦 Local Production
App Passed Failed Skipped
✅ astro-stable 69 0 14
✅ express-stable 69 0 14
✅ fastify-stable 69 0 14
✅ hono-stable 69 0 14
✅ nextjs-turbopack-canary 58 0 25
✅ nextjs-turbopack-stable 75 0 8
✅ nextjs-webpack-canary 58 0 25
✅ nextjs-webpack-stable 75 0 8
✅ nitro-stable 69 0 14
✅ nuxt-stable 69 0 14
✅ sveltekit-stable 69 0 14
✅ vite-stable 69 0 14
✅ 🐘 Local Postgres
App Passed Failed Skipped
✅ astro-stable 69 0 14
✅ express-stable 69 0 14
✅ fastify-stable 69 0 14
✅ hono-stable 69 0 14
✅ nextjs-turbopack-canary 58 0 25
✅ nextjs-turbopack-stable 75 0 8
✅ nextjs-webpack-canary 58 0 25
✅ nextjs-webpack-stable 75 0 8
✅ nitro-stable 69 0 14
✅ nuxt-stable 69 0 14
✅ sveltekit-stable 69 0 14
✅ vite-stable 69 0 14
✅ 🪟 Windows
App Passed Failed Skipped
✅ nextjs-turbopack 75 0 8
❌ 🌍 Community Worlds
App Passed Failed Skipped
✅ mongodb-dev 5 0 0
❌ mongodb 55 3 8
✅ redis-dev 5 0 0
❌ redis 56 2 8
✅ turso-dev 5 0 0
❌ turso 4 54 8
✅ 📋 Other
App Passed Failed Skipped
✅ e2e-local-dev-nest-stable 69 0 14
✅ e2e-local-postgres-nest-stable 69 0 14
✅ e2e-local-prod-nest-stable 69 0 14

📋 View full workflow run

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 26, 2026

📊 Benchmark Results

📈 Comparing against baseline from main branch. Green 🟢 = faster, Red 🔺 = slower.

workflow with no steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Express 0.043s (-8.3% 🟢) 1.005s (~) 0.962s 10 1.00x
💻 Local Nitro 0.044s (+1.6%) 1.005s (~) 0.961s 10 1.02x
🐘 Postgres Express 0.063s (+4.0%) 1.011s (~) 0.948s 10 1.45x
🐘 Postgres Nitro 0.070s (-3.5%) 1.011s (-1.0%) 0.941s 10 1.62x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 0.542s (+5.6% 🔺) 2.561s (-6.0% 🟢) 2.019s 10 1.00x
▲ Vercel Next.js (Turbopack) 0.754s (+12.0% 🔺) 2.792s (+4.3%) 2.038s 10 1.39x
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Express | Next.js (Turbopack)

workflow with 1 step

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Nitro 1.129s (~) 2.007s (~) 0.878s 10 1.00x
💻 Local Express 1.129s (~) 2.006s (~) 0.877s 10 1.00x
🐘 Postgres Nitro 1.141s (~) 2.010s (~) 0.869s 10 1.01x
🐘 Postgres Express 1.144s (~) 2.010s (~) 0.866s 10 1.01x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 2.603s (+13.5% 🔺) 3.815s (-3.1%) 1.211s 10 1.00x
▲ Vercel Express 3.345s (+58.0% 🔺) 5.505s (+42.8% 🔺) 2.160s 10 1.28x
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack) | Express

workflow with 10 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 10.839s (~) 11.025s (~) 0.186s 3 1.00x
💻 Local Nitro 10.914s (~) 11.024s (~) 0.110s 3 1.01x
🐘 Postgres Express 10.915s (+0.6%) 11.021s (~) 0.106s 3 1.01x
💻 Local Express 10.949s (~) 11.023s (~) 0.075s 3 1.01x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 17.584s (+0.7%) 19.411s (+3.4%) 1.827s 2 1.00x
▲ Vercel Next.js (Turbopack) 18.307s (+5.9% 🔺) 19.819s (+6.1% 🔺) 1.512s 2 1.04x
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Express | Next.js (Turbopack)

workflow with 25 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 14.455s (~) 15.021s (~) 0.566s 4 1.00x
🐘 Postgres Express 14.559s (~) 15.025s (~) 0.466s 4 1.01x
💻 Local Nitro 14.964s (~) 15.029s (~) 0.065s 4 1.04x
💻 Local Express 15.017s (~) 15.280s (+1.7%) 0.263s 4 1.04x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 32.151s (-4.3%) 33.381s (-5.7% 🟢) 1.229s 2 1.00x
▲ Vercel Express 33.147s (+6.2% 🔺) 35.153s (+7.2% 🔺) 2.007s 2 1.03x
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack) | Express

workflow with 50 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 13.957s (+1.2%) 14.314s (+2.1%) 0.357s 7 1.00x
🐘 Postgres Express 14.210s (+2.0%) 15.023s (+6.0% 🔺) 0.813s 6 1.02x
💻 Local Express 16.514s (-0.6%) 17.031s (~) 0.517s 6 1.18x
💻 Local Nitro 16.714s (+2.4%) 17.031s (~) 0.317s 6 1.20x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 57.825s (-1.6%) 59.469s (-1.8%) 1.644s 2 1.00x
▲ Vercel Next.js (Turbopack) 59.978s (+7.1% 🔺) 61.695s (+7.7% 🔺) 1.717s 2 1.04x
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Express | Next.js (Turbopack)

Promise.all with 10 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 1.277s (+1.7%) 2.010s (~) 0.733s 15 1.00x
🐘 Postgres Nitro 1.281s (+1.2%) 2.012s (~) 0.731s 15 1.00x
💻 Local Express 1.479s (~) 2.005s (~) 0.527s 15 1.16x
💻 Local Nitro 1.515s (+1.0%) 2.005s (~) 0.490s 15 1.19x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 2.574s (+4.8%) 4.083s (+1.7%) 1.509s 8 1.00x
▲ Vercel Next.js (Turbopack) 2.621s (+13.9% 🔺) 3.888s (+5.3% 🔺) 1.267s 8 1.02x
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Express | Next.js (Turbopack)

Promise.all with 25 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 2.340s (~) 3.012s (~) 0.671s 10 1.00x
🐘 Postgres Express 2.345s (+1.0%) 3.010s (~) 0.665s 10 1.00x
💻 Local Express 2.792s (-6.8% 🟢) 3.009s (-10.0% 🟢) 0.216s 10 1.19x
💻 Local Nitro 2.929s (+1.0%) 3.341s (+7.5% 🔺) 0.413s 9 1.25x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 2.898s (+7.7% 🔺) 4.203s (+9.2% 🔺) 1.304s 8 1.00x
▲ Vercel Express 2.943s (+13.8% 🔺) 4.399s (+8.3% 🔺) 1.456s 7 1.02x
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack) | Express

Promise.all with 50 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 3.481s (~) 4.012s (~) 0.532s 8 1.00x
🐘 Postgres Nitro 3.488s (+1.0%) 4.011s (~) 0.523s 8 1.00x
💻 Local Express 7.611s (-5.6% 🟢) 8.018s (-8.6% 🟢) 0.407s 4 2.19x
💻 Local Nitro 8.008s (-1.4%) 8.522s (-2.8%) 0.514s 4 2.30x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 3.229s (+9.8% 🔺) 4.569s (-4.2%) 1.340s 7 1.00x
▲ Vercel Next.js (Turbopack) 3.491s (+2.1%) 5.064s (~) 1.572s 6 1.08x
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Express | Next.js (Turbopack)

Promise.race with 10 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 1.256s (~) 2.010s (~) 0.754s 15 1.00x
🐘 Postgres Nitro 1.273s (+1.5%) 2.011s (~) 0.738s 15 1.01x
💻 Local Nitro 1.526s (+0.7%) 2.006s (~) 0.480s 15 1.21x
💻 Local Express 1.528s (-0.7%) 2.006s (~) 0.478s 15 1.22x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 2.396s (+12.3% 🔺) 3.880s (-2.8%) 1.484s 8 1.00x
▲ Vercel Next.js (Turbopack) 2.431s (+4.2%) 3.786s (+5.2% 🔺) 1.355s 8 1.01x
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Express | Next.js (Turbopack)

Promise.race with 25 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 2.315s (~) 3.010s (~) 0.695s 10 1.00x
🐘 Postgres Nitro 2.346s (~) 3.010s (~) 0.664s 10 1.01x
💻 Local Express 2.887s (-3.9%) 3.007s (-12.9% 🟢) 0.120s 10 1.25x
💻 Local Nitro 3.014s (-1.5%) 3.675s (-2.2%) 0.662s 9 1.30x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 2.729s (+18.6% 🔺) 4.514s (+16.2% 🔺) 1.785s 7 1.00x
▲ Vercel Next.js (Turbopack) 2.974s (+3.3%) 4.324s (+0.7%) 1.351s 8 1.09x
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Express | Next.js (Turbopack)

Promise.race with 50 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 3.470s (~) 4.014s (~) 0.543s 8 1.00x
🐘 Postgres Nitro 3.494s (+0.9%) 4.012s (~) 0.518s 8 1.01x
💻 Local Express 8.210s (-6.1% 🟢) 9.023s (~) 0.813s 4 2.37x
💻 Local Nitro 8.523s (+1.0%) 9.021s (~) 0.498s 4 2.46x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 2.975s (+6.9% 🔺) 4.317s (-3.3%) 1.342s 7 1.00x
▲ Vercel Next.js (Turbopack) 3.380s (-3.8%) 4.596s (-9.1% 🟢) 1.216s 7 1.14x
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Express | Next.js (Turbopack)

workflow with 10 sequential data payload steps (10KB)

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 0.821s (+1.5%) 1.008s (~) 0.186s 60 1.00x
🐘 Postgres Nitro 0.840s (+2.3%) 1.024s (~) 0.184s 59 1.02x
💻 Local Nitro 0.978s (+2.3%) 1.115s (+7.4% 🔺) 0.137s 54 1.19x
💻 Local Express 1.005s (+1.5%) 1.505s (+30.3% 🔺) 0.500s 40 1.22x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 9.903s (+2.7%) 11.684s (+1.3%) 1.780s 6 1.00x
▲ Vercel Next.js (Turbopack) 10.351s (-5.2% 🟢) 11.644s (-5.5% 🟢) 1.292s 6 1.05x
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Express | Next.js (Turbopack)

workflow with 25 sequential data payload steps (10KB)

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 1.910s (+2.0%) 2.101s (+2.3%) 0.191s 43 1.00x
🐘 Postgres Express 1.940s (+3.0%) 2.175s (+7.2% 🔺) 0.235s 42 1.02x
💻 Local Nitro 3.009s (+2.2%) 3.547s (+15.4% 🔺) 0.538s 26 1.58x
💻 Local Express 3.023s (+1.0%) 3.689s (+9.2% 🔺) 0.666s 25 1.58x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 28.942s (-4.5%) 31.242s (-3.0%) 2.300s 3 1.00x
▲ Vercel Next.js (Turbopack) 31.123s (-3.2%) 32.641s (-2.9%) 1.518s 3 1.08x
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Express | Next.js (Turbopack)

workflow with 50 sequential data payload steps (10KB)

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 3.869s (+0.7%) 4.111s (+2.5%) 0.242s 30 1.00x
🐘 Postgres Express 3.927s (+2.2%) 4.150s (+2.6%) 0.223s 29 1.02x
💻 Local Express 9.026s (-0.6%) 9.556s (~) 0.529s 13 2.33x
💻 Local Nitro 9.103s (+2.0%) 9.633s (+4.2%) 0.530s 13 2.35x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 82.582s (+2.2%) 84.849s (+2.4%) 2.267s 2 1.00x
▲ Vercel Next.js (Turbopack) 86.270s (+1.0%) 87.899s (+0.9%) 1.629s 2 1.04x
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Express | Next.js (Turbopack)

workflow with 10 concurrent data payload steps (10KB)

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 0.272s (-2.1%) 1.008s (~) 0.735s 60 1.00x
🐘 Postgres Express 0.282s (+3.6%) 1.008s (~) 0.726s 60 1.04x
💻 Local Express 0.603s (+0.5%) 1.022s (+1.7%) 0.418s 59 2.21x
💻 Local Nitro 0.618s (+5.3% 🔺) 1.021s (+1.7%) 0.403s 59 2.27x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 1.595s (-5.4% 🟢) 3.100s (-6.8% 🟢) 1.505s 20 1.00x
▲ Vercel Next.js (Turbopack) 1.622s (-20.0% 🟢) 3.330s (-10.4% 🟢) 1.708s 19 1.02x
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Express | Next.js (Turbopack)

workflow with 25 concurrent data payload steps (10KB)

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 0.501s (+0.6%) 1.007s (~) 0.507s 90 1.00x
🐘 Postgres Express 0.501s (+2.0%) 1.007s (~) 0.506s 90 1.00x
💻 Local Express 2.435s (-2.5%) 3.009s (~) 0.574s 30 4.86x
💻 Local Nitro 2.492s (+1.7%) 3.009s (~) 0.517s 30 4.98x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 2.869s (+3.1%) 4.585s (-1.4%) 1.716s 20 1.00x
▲ Vercel Next.js (Turbopack) 3.391s (-90.9% 🟢) 4.854s (-87.6% 🟢) 1.462s 19 1.18x
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Express | Next.js (Turbopack)

workflow with 50 concurrent data payload steps (10KB)

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 0.770s (~) 1.008s (~) 0.238s 120 1.00x
🐘 Postgres Express 0.781s (+1.8%) 1.008s (~) 0.227s 120 1.01x
💻 Local Express 10.477s (-5.0% 🟢) 11.029s (-5.5% 🟢) 0.551s 11 13.61x
💻 Local Nitro 11.107s (+2.2%) 11.664s (+1.6%) 0.557s 11 14.43x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 7.151s (-1.9%) 8.767s (-2.0%) 1.616s 14 1.00x
▲ Vercel Next.js (Turbopack) 8.055s (+3.0%) 9.529s (-0.7%) 1.475s 13 1.13x
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Express | Next.js (Turbopack)

Stream Benchmarks (includes TTFB metrics)
workflow with stream

💻 Local Development

World Framework Workflow Time TTFB Slurp Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Nitro 0.203s (+1.7%) 1.003s (~) 0.012s (+8.4% 🔺) 1.018s (~) 0.815s 10 1.00x
💻 Local Express 0.206s (-1.1%) 1.003s (~) 0.011s (-8.7% 🟢) 1.017s (~) 0.810s 10 1.02x
🐘 Postgres Nitro 0.218s (+6.4% 🔺) 0.995s (~) 0.002s (+15.4% 🔺) 1.013s (~) 0.794s 10 1.07x
🐘 Postgres Express 0.222s (+11.6% 🔺) 0.993s (~) 0.001s (~) 1.011s (~) 0.789s 10 1.09x
💻 Local Next.js (Turbopack) ⚠️ missing - - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - - -

▲ Production (Vercel)

World Framework Workflow Time TTFB Slurp Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 1.677s (+4.5%) 2.859s (+12.4% 🔺) 0.391s (-31.3% 🟢) 3.901s (+5.5% 🔺) 2.224s 10 1.00x
▲ Vercel Express 1.793s (+11.7% 🔺) 2.850s (+7.1% 🔺) 0.325s (-42.6% 🟢) 3.965s (+1.1%) 2.172s 10 1.07x
▲ Vercel Nitro ⚠️ missing - - - - -

🔍 Observability: Next.js (Turbopack) | Express

stream pipeline with 5 transform steps (1MB)

💻 Local Development

World Framework Workflow Time TTFB Slurp Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 0.599s (+0.6%) 1.002s (~) 0.004s (-7.4% 🟢) 1.025s (~) 0.426s 59 1.00x
🐘 Postgres Nitro 0.601s (+1.8%) 1.004s (~) 0.004s (~) 1.024s (~) 0.423s 59 1.00x
💻 Local Nitro 0.724s (+1.7%) 1.009s (~) 0.009s (+2.1%) 1.024s (~) 0.299s 59 1.21x
💻 Local Express 0.746s (+2.7%) 1.010s (~) 0.009s (-5.2% 🟢) 1.023s (~) 0.277s 59 1.25x
💻 Local Next.js (Turbopack) ⚠️ missing - - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - - -

▲ Production (Vercel)

World Framework Workflow Time TTFB Slurp Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 4.033s (+1.7%) 5.197s (-2.6%) 0.277s (+27.9% 🔺) 6.102s (-2.4%) 2.069s 10 1.00x
▲ Vercel Next.js (Turbopack) 4.593s (+3.1%) 5.553s (~) 0.244s (-6.2% 🟢) 6.378s (-6.9% 🟢) 1.785s 10 1.14x
▲ Vercel Nitro ⚠️ missing - - - - -

🔍 Observability: Express | Next.js (Turbopack)

10 parallel streams (1MB each)

💻 Local Development

World Framework Workflow Time TTFB Slurp Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 0.984s (+4.9%) 1.277s (+2.9%) 0.000s (+4.3%) 1.306s (+3.7%) 0.322s 46 1.00x
🐘 Postgres Nitro 0.993s (+2.9%) 1.455s (+17.2% 🔺) 0.000s (-61.0% 🟢) 1.480s (+17.5% 🔺) 0.487s 41 1.01x
💻 Local Express 1.202s (-4.4%) 2.019s (~) 0.000s (-27.3% 🟢) 2.023s (~) 0.820s 30 1.22x
💻 Local Nitro 1.245s (+2.8%) 2.022s (~) 0.000s (~) 2.025s (~) 0.780s 30 1.26x
💻 Local Next.js (Turbopack) ⚠️ missing - - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - - -

▲ Production (Vercel)

World Framework Workflow Time TTFB Slurp Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 3.001s (+9.6% 🔺) 4.121s (+13.7% 🔺) 0.000s (NaN%) 4.769s (+10.9% 🔺) 1.768s 13 1.00x
▲ Vercel Next.js (Turbopack) 3.558s (+20.6% 🔺) 4.563s (+10.9% 🔺) 0.001s (+Infinity% 🔺) 5.146s (+10.0% 🔺) 1.588s 12 1.19x
▲ Vercel Nitro ⚠️ missing - - - - -

🔍 Observability: Express | Next.js (Turbopack)

fan-out fan-in 10 streams (1MB each)

💻 Local Development

World Framework Workflow Time TTFB Slurp Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 1.765s (+3.1%) 2.173s (+3.4%) 0.000s (-100.0% 🟢) 2.189s (+3.5%) 0.424s 28 1.00x
🐘 Postgres Nitro 1.814s (+4.6%) 2.176s (~) 0.000s (-31.0% 🟢) 2.190s (~) 0.376s 28 1.03x
💻 Local Express 3.395s (-5.6% 🟢) 4.033s (-1.6%) 0.001s (~) 4.037s (-1.6%) 0.642s 15 1.92x
💻 Local Nitro 3.529s (~) 4.032s (~) 0.001s (+42.9% 🔺) 4.036s (~) 0.507s 15 2.00x
💻 Local Next.js (Turbopack) ⚠️ missing - - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - - -

▲ Production (Vercel)

World Framework Workflow Time TTFB Slurp Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 4.296s (-92.2% 🟢) 5.096s (+3.2%) 0.000s (+Infinity% 🔺) 5.683s (-89.9% 🟢) 1.388s 11 1.00x
▲ Vercel Express 4.322s (-72.6% 🟢) 5.319s (-68.8% 🟢) 0.000s (NaN%) 6.044s (-65.9% 🟢) 1.722s 10 1.01x
▲ Vercel Nitro ⚠️ missing - - - - -

🔍 Observability: Next.js (Turbopack) | Express

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World 🥇 Fastest Framework Wins
💻 Local Express 13/21
🐘 Postgres Nitro 11/21
▲ Vercel Express 16/21
Fastest World by Framework

Winner determined by most benchmark wins

Framework 🥇 Fastest World Wins
Express 🐘 Postgres 16/21
Next.js (Turbopack) ▲ Vercel 21/21
Nitro 🐘 Postgres 18/21
Column Definitions
  • Workflow Time: Runtime reported by workflow (completedAt - createdAt) - primary metric
  • TTFB: Time to First Byte - time from workflow start until first stream byte received (stream benchmarks only)
  • Slurp: Time from first byte to complete stream consumption (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • Samples: Number of benchmark iterations run
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world (local development)
  • 🐘 Postgres: PostgreSQL database world (local development)
  • ▲ Vercel: Vercel production/preview deployment
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)

📋 View full workflow run


Some benchmark jobs failed:

  • Local: success
  • Postgres: success
  • Vercel: failure

Check the workflow run for details.

@vercel vercel bot temporarily deployed to Preview – workflow-docs March 26, 2026 06:48 Inactive
The dirs option was introduced to narrow file scanning, but the
root causes (TS extension rewriting, stale bundle rediscovery,
eager bundle loading) are addressed by the other fixes in this PR.
Keeping dirs: ['.'] as the hardcoded default.
@matchai
Copy link
Copy Markdown
Member Author

matchai commented Mar 26, 2026

@pranaygp Good call — removed the dirs option entirely. The root cause was actually the eager bundle loading, not the scan scope. With lazy handlers deferring import() until first dispatch, dirs: ['.'] works fine.

Copy link
Copy Markdown
Member

@VaguelySerious VaguelySerious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review: no blocking issues

externalPath = externalPath
.replace(/\.tsx?$/, '.js')
.replace(/\.mts$/, '.mjs')
.replace(/\.cts$/, '.cjs');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review: Note

The extension rewriting regex chain is correct — .ts/.tsx.js, .mts.mjs, .cts.cjs with no cross-matching. However, this fix benefits ALL 6 framework builders that use externalizeNonSteps (next, astro, sveltekit, nitro, nest), not just vitest. This is a production correctness fix worth calling out in the changeset.

Also note: this only applies when enhanced-resolve successfully resolves the import. Imports using the TypeScript ESM convention (from './dep.js' where the file is dep.ts) silently fail in enhanced-resolve, fall through to esbuild's built-in resolver, and get inlined instead of externalized. This is pre-existing and out of scope, but worth being aware of — it means local step dependencies with .js import specifiers can't be mocked.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was something to this to that it seemed see #1555 cc @matchai @VaguelySerious

Comment thread docs/content/docs/testing/index.mdx Outdated

<Callout type="warn">
Inside integration tests, which run the full workflow runtime, `vi.mock()` and related calls do not work — neither for your own modules nor for third-party npm packages. All step dependencies are inlined into the compiled bundle by esbuild, bypassing Vitest's module system entirely. To test steps with mocked dependencies, use [unit tests](#unit-testing-steps) instead. Consider dependency injection or environment variable-based conditional logic for controlling behavior in integration tests.
`vi.mock()` and related calls do _not_ work inside workflow functions, only step functions. Your workflow functions may not import third party code that needs to be mocked. If something needs to be mocked, it likely belongs inside a step function either way.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review: Nit

"may not" is ambiguous — could be read as possibility ("might not") or prohibition ("must not"). Consider "must not" or "cannot" for clarity.

Also, vi.mock() works for externalized step dependencies (npm packages and extensionless local imports), but NOT for local dependencies imported with .js extensions (pre-existing limitation where enhanced-resolve can't resolve .js.ts). Consider adding a note like "Mocking works for npm packages imported in step functions" to set expectations precisely.

}
return handler(req);
};
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review: Note

Good pattern — the loading ??= memoization correctly deduplicates concurrent dispatches. One subtlety: if the import() rejects (e.g., bundle file missing/corrupt), the rejected promise is cached and all subsequent handler calls immediately reject with the same error. This is appropriate fail-fast behavior for a test runner, but a brief comment noting this would help future readers understand the intentional design.

Comment thread packages/vitest/src/index.ts Outdated
return [
workflowTransformPlugin(),
workflowTransformPlugin({
exclude: [join(process.cwd(), '.workflow-vitest')],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review: Nit

The startsWith matching in workflowTransformPlugin's exclude check would also match a hypothetical .workflow-vitest-backup/ directory. Appending a / to the exclude path (join(process.cwd(), '.workflow-vitest') + '/') would make matching more precise. Very unlikely to matter in practice.

VaguelySerious and others added 3 commits March 26, 2026 14:39
…add comment

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Peter Wielander <mittgfu@gmail.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.

4 participants