Skip to content

Add additional tests for event consumer fixes for hook/sleep/step race conditions#1528

Merged
VaguelySerious merged 1 commit intomainfrom
fix/unconsumed-event-false-positive-hook-step
May 2, 2026
Merged

Add additional tests for event consumer fixes for hook/sleep/step race conditions#1528
VaguelySerious merged 1 commit intomainfrom
fix/unconsumed-event-false-positive-hook-step

Conversation

@pranaygp
Copy link
Copy Markdown
Contributor

@pranaygp pranaygp commented Mar 26, 2026

Fix shipped in #1778, so this PR now only adds tests, see old description below


Summary

  • Fixes a race condition in EventsConsumer where a step_created event could be falsely flagged as unconsumed during replay of for await (const payload of hook) { await step(payload); } patterns
  • After the promise queue drains (e.g., step result deserialization), yields to the event loop before re-checking, allowing microtask chains to propagate and append a second round of async work (hook payload deserialization)
  • Adds a unit test reproducing the exact event log pattern from the CI failure (alternating hook_received + step lifecycle events)

Root Cause

During replay, the EventsConsumer advances through events via process.nextTick. When it reaches a step_created event for the second loop iteration, no step consumer exists yet because:

  1. The preceding step_completed deserialization resolves processPayload() → triggers for-await loop continuation
  2. The loop calls createHookPromise() → chains hook payload deserialization onto the promise queue
  3. After hook deserialization → for-await yields → processPayload() called → step consumer registered

The existing deferred check only chained onto the promise queue once, missing the second round of async work added in step 2. The fix adds a setTimeout(0) yield between queue drains to let microtask chains propagate.

CI Failure

Test plan

  • All 22 events-consumer.test.ts tests pass
  • All 16 hook-sleep-interaction.test.ts tests pass (including new test)
  • All 71 workflow.test.ts tests pass
  • All other related test files pass (166 tests total)

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings March 26, 2026 23:03
@pranaygp pranaygp requested a review from a team as a code owner March 26, 2026 23:03
@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 May 2, 2026 6:51am
example-nextjs-workflow-webpack Ready Ready Preview, Comment May 2, 2026 6:51am
example-workflow Ready Ready Preview, Comment May 2, 2026 6:51am
workbench-astro-workflow Ready Ready Preview, Comment May 2, 2026 6:51am
workbench-express-workflow Ready Ready Preview, Comment May 2, 2026 6:51am
workbench-fastify-workflow Ready Ready Preview, Comment May 2, 2026 6:51am
workbench-hono-workflow Ready Ready Preview, Comment May 2, 2026 6:51am
workbench-nitro-workflow Ready Ready Preview, Comment May 2, 2026 6:51am
workbench-nuxt-workflow Ready Ready Preview, Comment May 2, 2026 6:51am
workbench-sveltekit-workflow Ready Ready Preview, Comment May 2, 2026 6:51am
workbench-vite-workflow Ready Ready Preview, Comment May 2, 2026 6:51am
workflow-docs Ready Ready Preview, Comment, Open in v0 May 2, 2026 6:51am
workflow-swc-playground Ready Ready Preview, Comment May 2, 2026 6:51am
workflow-web Ready Ready Preview, Comment May 2, 2026 6:51am

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 26, 2026

⚠️ No Changeset found

Latest commit: 7d25955

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@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 🥇 Nitro 0.043s (-1.4%) 1.006s (~) 0.963s 10 1.00x
💻 Local Express 0.045s (+2.3%) 1.006s (~) 0.961s 10 1.07x
🐘 Postgres Express 0.060s (+2.8%) 1.009s (~) 0.949s 10 1.40x
🐘 Postgres Nitro 0.060s (-36.4% 🟢) 1.010s (-3.2%) 0.949s 10 1.42x
💻 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) 0.221s (-12.2% 🟢) 2.282s (-2.2%) 2.061s 10 1.00x
▲ Vercel Express ⚠️ missing - - - -
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack)

workflow with 1 step

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Nitro 1.130s (~) 2.006s (~) 0.876s 10 1.00x
💻 Local Express 1.132s (+0.6%) 2.007s (~) 0.875s 10 1.00x
🐘 Postgres Nitro 1.146s (+0.5%) 2.010s (~) 0.864s 10 1.01x
🐘 Postgres Express 1.151s (~) 2.010s (~) 0.859s 10 1.02x
💻 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.346s (+15.3% 🔺) 3.986s (+4.1%) 1.640s 10 1.00x
▲ Vercel Express ⚠️ missing - - - -
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack)

workflow with 10 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 10.868s (-0.9%) 11.025s (~) 0.157s 3 1.00x
🐘 Postgres Nitro 10.931s (+0.6%) 11.020s (~) 0.089s 3 1.01x
💻 Local Nitro 10.943s (~) 11.024s (~) 0.081s 3 1.01x
💻 Local Express 10.970s (~) 11.026s (~) 0.055s 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 🥇 Next.js (Turbopack) 20.894s (+20.6% 🔺) 22.626s (+16.6% 🔺) 1.732s 2 1.00x
▲ Vercel Express ⚠️ missing - - - -
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack)

workflow with 25 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 14.535s (~) 15.021s (~) 0.486s 4 1.00x
🐘 Postgres Express 14.586s (~) 15.025s (~) 0.438s 4 1.00x
💻 Local Nitro 14.993s (~) 15.030s (-6.2% 🟢) 0.037s 4 1.03x
💻 Local Express 15.009s (~) 15.530s (+3.3%) 0.521s 4 1.03x
💻 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) 35.218s (-33.0% 🟢) 37.096s (-32.1% 🟢) 1.878s 2 1.00x
▲ Vercel Express ⚠️ missing - - - -
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack)

workflow with 50 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 13.962s (~) 14.305s (-2.0%) 0.343s 7 1.00x
🐘 Postgres Nitro 13.992s (~) 14.589s (+2.0%) 0.597s 7 1.00x
💻 Local Express 16.689s (+0.5%) 17.031s (~) 0.342s 6 1.20x
💻 Local Nitro 16.809s (~) 17.032s (~) 0.224s 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 🥇 Next.js (Turbopack) 63.535s (-83.9% 🟢) 65.369s (-83.5% 🟢) 1.835s 2 1.00x
▲ Vercel Express ⚠️ missing - - - -
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack)

Promise.all with 10 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 1.270s (~) 2.009s (~) 0.739s 15 1.00x
🐘 Postgres Express 1.285s (+1.9%) 2.009s (~) 0.725s 15 1.01x
💻 Local Nitro 1.532s (-6.1% 🟢) 2.005s (-3.3%) 0.474s 15 1.21x
💻 Local Express 1.544s (+3.7%) 2.006s (~) 0.463s 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 🥇 Next.js (Turbopack) 2.747s (-19.1% 🟢) 4.836s (-2.0%) 2.089s 7 1.00x
▲ Vercel Express ⚠️ missing - - - -
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack)

Promise.all with 25 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 2.321s (-1.3%) 3.010s (~) 0.688s 10 1.00x
🐘 Postgres Express 2.334s (-1.2%) 3.010s (~) 0.676s 10 1.01x
💻 Local Express 2.915s (-1.3%) 3.342s (-3.2%) 0.427s 9 1.26x
💻 Local Nitro 3.037s (-3.4%) 3.676s (-5.4% 🟢) 0.640s 9 1.31x
💻 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.884s (-59.4% 🟢) 4.602s (-48.3% 🟢) 1.717s 7 1.00x
▲ Vercel Express ⚠️ missing - - - -
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack)

Promise.all with 50 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 3.466s (-0.6%) 4.010s (~) 0.544s 8 1.00x
🐘 Postgres Nitro 3.495s (~) 4.011s (~) 0.516s 8 1.01x
💻 Local Nitro 8.200s (-1.8%) 9.023s (~) 0.822s 4 2.37x
💻 Local Express 8.353s (~) 9.023s (~) 0.670s 4 2.41x
💻 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) 3.519s (-60.5% 🟢) 4.894s (-55.4% 🟢) 1.374s 7 1.00x
▲ Vercel Express ⚠️ missing - - - -
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack)

Promise.race with 10 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 1.248s (-0.7%) 2.009s (~) 0.761s 15 1.00x
🐘 Postgres Nitro 1.275s (+1.4%) 2.008s (~) 0.733s 15 1.02x
💻 Local Nitro 1.540s (-17.5% 🟢) 2.006s (-14.3% 🟢) 0.466s 15 1.23x
💻 Local Express 1.551s (-18.1% 🟢) 2.006s (-15.1% 🟢) 0.455s 15 1.24x
💻 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) 5.138s (+75.3% 🔺) 6.583s (+41.8% 🔺) 1.446s 5 1.00x
▲ Vercel Express ⚠️ missing - - - -
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack)

Promise.race with 25 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 2.336s (~) 3.011s (~) 0.675s 10 1.00x
🐘 Postgres Nitro 2.353s (+0.6%) 3.011s (~) 0.658s 10 1.01x
💻 Local Express 3.042s (-2.9%) 3.676s (-2.3%) 0.634s 9 1.30x
💻 Local Nitro 3.145s (+2.6%) 3.884s (~) 0.740s 8 1.35x
💻 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.811s (-10.6% 🟢) 4.400s (-2.7%) 1.589s 7 1.00x
▲ Vercel Express ⚠️ missing - - - -
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack)

Promise.race with 50 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 3.484s (~) 4.012s (~) 0.528s 8 1.00x
🐘 Postgres Nitro 3.488s (~) 4.009s (~) 0.521s 8 1.00x
💻 Local Express 8.866s (+0.7%) 9.273s (~) 0.407s 4 2.54x
💻 Local Nitro 8.892s (-2.8%) 9.525s (-5.0%) 0.633s 4 2.55x
💻 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) 3.217s (-52.4% 🟢) 5.450s (-36.2% 🟢) 2.234s 6 1.00x
▲ Vercel Express ⚠️ missing - - - -
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: 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.824s (-1.8%) 1.040s (+1.7%) 0.216s 58 1.00x
🐘 Postgres Nitro 0.831s (+1.3%) 1.006s (~) 0.175s 60 1.01x
💻 Local Nitro 0.996s (+1.6%) 1.309s (+19.7% 🔺) 0.313s 46 1.21x
💻 Local Express 0.999s (+1.5%) 1.369s (+27.2% 🔺) 0.370s 44 1.21x
💻 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) 9.765s (-32.7% 🟢) 11.395s (-29.2% 🟢) 1.630s 6 1.00x
▲ Vercel Express ⚠️ missing - - - -
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack)

workflow with 25 sequential data payload steps (10KB)

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 1.937s (-2.0%) 2.174s (-3.7%) 0.237s 42 1.00x
🐘 Postgres Nitro 1.947s (+1.0%) 2.227s (+6.0% 🔺) 0.281s 41 1.01x
💻 Local Express 3.027s (~) 3.729s (+4.0%) 0.702s 25 1.56x
💻 Local Nitro 3.041s (~) 3.924s (+4.4%) 0.883s 23 1.57x
💻 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) 29.356s (-41.1% 🟢) 32.421s (-37.3% 🟢) 3.065s 3 1.00x
▲ Vercel Express ⚠️ missing - - - -
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack)

workflow with 50 sequential data payload steps (10KB)

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 3.956s (-0.9%) 4.295s (-1.7%) 0.339s 28 1.00x
🐘 Postgres Nitro 3.979s (-3.0%) 4.440s (-3.6%) 0.461s 28 1.01x
💻 Local Nitro 9.239s (-0.6%) 9.942s (-0.8%) 0.703s 13 2.34x
💻 Local Express 9.278s (+0.7%) 10.019s (~) 0.741s 12 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 🥇 Next.js (Turbopack) 75.851s (-29.2% 🟢) 78.156s (-28.2% 🟢) 2.305s 2 1.00x
▲ Vercel Express ⚠️ missing - - - -
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack)

workflow with 10 concurrent data payload steps (10KB)

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 0.281s (-0.6%) 1.007s (~) 0.727s 60 1.00x
🐘 Postgres Nitro 0.294s (+3.8%) 1.007s (~) 0.713s 60 1.05x
💻 Local Express 0.606s (+8.2% 🔺) 1.005s (~) 0.398s 60 2.16x
💻 Local Nitro 0.682s (+12.8% 🔺) 1.096s (+7.3% 🔺) 0.414s 55 2.43x
💻 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.488s (+23.0% 🔺) 3.844s (+1.3%) 1.355s 16 1.00x
▲ Vercel Express ⚠️ missing - - - -
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack)

workflow with 25 concurrent data payload steps (10KB)

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 0.495s (-2.9%) 1.007s (~) 0.511s 90 1.00x
🐘 Postgres Nitro 0.507s (+2.2%) 1.008s (~) 0.501s 90 1.02x
💻 Local Nitro 2.547s (~) 3.009s (~) 0.462s 30 5.14x
💻 Local Express 2.736s (+8.9% 🔺) 3.182s (+5.7% 🔺) 0.445s 29 5.53x
💻 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) 3.259s (-7.8% 🟢) 5.048s (-2.8%) 1.790s 18 1.00x
▲ Vercel Express ⚠️ missing - - - -
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack)

workflow with 50 concurrent data payload steps (10KB)

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 0.799s (-2.4%) 1.008s (-0.9%) 0.209s 119 1.00x
🐘 Postgres Nitro 0.814s (+3.0%) 1.018s (+1.0%) 0.204s 118 1.02x
💻 Local Express 11.153s (~) 11.667s (-2.3%) 0.514s 11 13.95x
💻 Local Nitro 11.162s (~) 11.847s (+1.6%) 0.685s 11 13.97x
💻 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) 6.273s (-39.3% 🟢) 7.923s (-35.5% 🟢) 1.649s 16 1.00x
▲ Vercel Express ⚠️ missing - - - -
▲ Vercel Nitro ⚠️ missing - - - -

🔍 Observability: 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
🐘 Postgres 🥇 Express 0.201s (-2.2%) 0.999s (~) 0.001s (-12.5% 🟢) 1.010s (~) 0.810s 10 1.00x
💻 Local Express 0.204s (+2.4%) 1.004s (~) 0.012s (+0.8%) 1.018s (~) 0.814s 10 1.02x
💻 Local Nitro 0.205s (-4.1%) 1.004s (~) 0.013s (+2.4%) 1.019s (~) 0.814s 10 1.02x
🐘 Postgres Nitro 0.210s (+2.3%) 0.995s (~) 0.002s (+6.7% 🔺) 1.011s (~) 0.801s 10 1.05x
💻 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.766s (-74.2% 🟢) 3.411s (-60.6% 🟢) 1.713s (+171.1% 🔺) 5.496s (-43.8% 🟢) 3.730s 10 1.00x
▲ Vercel Express ⚠️ missing - - - - -
▲ Vercel Nitro ⚠️ missing - - - - -

🔍 Observability: Next.js (Turbopack)

stream pipeline with 5 transform steps (1MB)

💻 Local Development

World Framework Workflow Time TTFB Slurp Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 0.606s (-3.7%) 1.006s (~) 0.004s (+1.3%) 1.021s (~) 0.415s 59 1.00x
🐘 Postgres Nitro 0.629s (+0.8%) 1.008s (~) 0.004s (-4.9%) 1.023s (~) 0.394s 59 1.04x
💻 Local Nitro 0.762s (-9.1% 🟢) 1.011s (~) 0.012s (+24.4% 🔺) 1.025s (-8.2% 🟢) 0.262s 59 1.26x
💻 Local Express 0.940s (+24.2% 🔺) 1.012s (-1.7%) 0.010s (+9.2% 🔺) 1.213s (+16.7% 🔺) 0.273s 53 1.55x
💻 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.974s (-70.6% 🟢) 6.236s (-65.8% 🟢) 0.208s (-1.6%) 7.014s (-63.0% 🟢) 2.040s 9 1.00x
▲ Vercel Express ⚠️ missing - - - - -
▲ Vercel Nitro ⚠️ missing - - - - -

🔍 Observability: 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.970s (+0.9%) 1.218s (-4.7%) 0.000s (-6.1% 🟢) 1.232s (-5.7% 🟢) 0.263s 49 1.00x
🐘 Postgres Nitro 1.003s (+3.6%) 1.533s (+22.9% 🔺) 0.000s (+23.1% 🔺) 1.554s (+23.5% 🔺) 0.550s 39 1.03x
💻 Local Express 1.226s (~) 2.020s (~) 0.001s (+50.0% 🔺) 2.022s (~) 0.796s 30 1.26x
💻 Local Nitro 1.255s (+2.6%) 2.023s (~) 0.000s (+266.7% 🔺) 2.025s (~) 0.770s 30 1.29x
💻 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) 3.333s (-67.3% 🟢) 4.717s (-59.1% 🟢) 0.000s (NaN%) 5.126s (-57.5% 🟢) 1.793s 12 1.00x
▲ Vercel Express ⚠️ missing - - - - -
▲ Vercel Nitro ⚠️ missing - - - - -

🔍 Observability: 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.736s (-2.0%) 2.102s (-3.5%) 0.000s (NaN%) 2.123s (-3.4%) 0.387s 29 1.00x
🐘 Postgres Nitro 1.814s (+1.3%) 2.067s (-3.5%) 0.000s (-3.4%) 2.111s (-2.9%) 0.297s 29 1.04x
💻 Local Express 3.556s (+2.5%) 4.031s (~) 0.000s (-66.7% 🟢) 4.035s (~) 0.479s 15 2.05x
💻 Local Nitro 3.572s (+5.5% 🔺) 4.034s (~) 0.001s (+62.5% 🔺) 4.037s (~) 0.465s 15 2.06x
💻 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.303s (-23.4% 🟢) 5.607s (-19.7% 🟢) 0.000s (-100.0% 🟢) 6.309s (-16.3% 🟢) 2.006s 10 1.00x
▲ Vercel Express ⚠️ missing - - - - -
▲ Vercel Nitro ⚠️ missing - - - - -

🔍 Observability: Next.js (Turbopack)

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World 🥇 Fastest Framework Wins
💻 Local Nitro 11/21
🐘 Postgres Express 17/21
▲ Vercel Next.js (Turbopack) 21/21
Fastest World by Framework

Winner determined by most benchmark wins

Framework 🥇 Fastest World Wins
Express 🐘 Postgres 19/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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 26, 2026

🧪 E2E Test Results

All tests passed

Summary

Passed Failed Skipped Total
✅ ▲ Vercel Production 1011 0 67 1078
✅ 💻 Local Development 1090 0 86 1176
✅ 📦 Local Production 1090 0 86 1176
✅ 🐘 Local Postgres 1090 0 86 1176
✅ 🪟 Windows 98 0 0 98
✅ 📋 Other 276 0 18 294
Total 4655 0 343 4998

Details by Category

✅ ▲ Vercel Production
App Passed Failed Skipped
✅ astro 91 0 7
✅ example 91 0 7
✅ express 91 0 7
✅ fastify 91 0 7
✅ hono 91 0 7
✅ nextjs-turbopack 96 0 2
✅ nextjs-webpack 96 0 2
✅ nitro 91 0 7
✅ nuxt 91 0 7
✅ sveltekit 91 0 7
✅ vite 91 0 7
✅ 💻 Local Development
App Passed Failed Skipped
✅ astro-stable 92 0 6
✅ express-stable 92 0 6
✅ fastify-stable 92 0 6
✅ hono-stable 92 0 6
✅ nextjs-turbopack-canary 79 0 19
✅ nextjs-turbopack-stable 98 0 0
✅ nextjs-webpack-canary 79 0 19
✅ nextjs-webpack-stable 98 0 0
✅ nitro-stable 92 0 6
✅ nuxt-stable 92 0 6
✅ sveltekit-stable 92 0 6
✅ vite-stable 92 0 6
✅ 📦 Local Production
App Passed Failed Skipped
✅ astro-stable 92 0 6
✅ express-stable 92 0 6
✅ fastify-stable 92 0 6
✅ hono-stable 92 0 6
✅ nextjs-turbopack-canary 79 0 19
✅ nextjs-turbopack-stable 98 0 0
✅ nextjs-webpack-canary 79 0 19
✅ nextjs-webpack-stable 98 0 0
✅ nitro-stable 92 0 6
✅ nuxt-stable 92 0 6
✅ sveltekit-stable 92 0 6
✅ vite-stable 92 0 6
✅ 🐘 Local Postgres
App Passed Failed Skipped
✅ astro-stable 92 0 6
✅ express-stable 92 0 6
✅ fastify-stable 92 0 6
✅ hono-stable 92 0 6
✅ nextjs-turbopack-canary 79 0 19
✅ nextjs-turbopack-stable 98 0 0
✅ nextjs-webpack-canary 79 0 19
✅ nextjs-webpack-stable 98 0 0
✅ nitro-stable 92 0 6
✅ nuxt-stable 92 0 6
✅ sveltekit-stable 92 0 6
✅ vite-stable 92 0 6
✅ 🪟 Windows
App Passed Failed Skipped
✅ nextjs-turbopack 98 0 0
✅ 📋 Other
App Passed Failed Skipped
✅ e2e-local-dev-nest-stable 92 0 6
✅ e2e-local-postgres-nest-stable 92 0 6
✅ e2e-local-prod-nest-stable 92 0 6

📋 View full workflow run

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a replay-time race in EventsConsumer where step_created could be incorrectly treated as orphaned in for await (const payload of hook) { await step(payload) } patterns, by adding an additional event-loop yield + promise-queue re-check before triggering the deferred “unconsumed event” failure path.

Changes:

  • Update EventsConsumer’s deferred unconsumed-event check to drain the promise queue, yield to the event loop, then drain again before scheduling the final delayed check.
  • Add a unit test reproducing the CI event-log pattern (alternating hook_received and step lifecycle events) for the hook + sleep + per-payload step scenario.
  • Add a patch changeset for @workflow/core.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/core/src/events-consumer.ts Adds a second promise-queue drain after a setTimeout(0) yield to avoid false-positive unconsumed events during replay.
packages/core/src/hook-sleep-interaction.test.ts Adds regression coverage for for await hook loops that call a step per payload while a sleep is pending.
.changeset/fix-unconsumed-event-hook-step-loop.md Declares a patch release for the core fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +118 to +127
.then(
// Yield to the event loop after the first queue drain. This allows
// microtask chains triggered by the preceding resolve() (e.g., a
// step result delivery that resumes a for-await loop, which then
// calls createHookPromise and appends a second round of async work
// to the promise queue) to propagate before we re-check the queue.
() => new Promise<void>((resolve) => setTimeout(resolve, 0))
)
.then(() => this.getPromiseQueue())
.then(() => {
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

The deferred check promise chain always schedules the extra timer(s) even if a later subscribe() has already invalidated checkVersion. This can leave behind unnecessary timers (including the new setTimeout(0) yield) under high churn, keeping the event loop alive and doing extra work even though the check can never fire. Consider short‑circuiting before scheduling the setTimeout (and/or before the second getPromiseQueue() call) when this.unconsumedCheckVersion !== checkVersion so cancellation is cheap and no timers are created for stale checks.

Suggested change
.then(
// Yield to the event loop after the first queue drain. This allows
// microtask chains triggered by the preceding resolve() (e.g., a
// step result delivery that resumes a for-await loop, which then
// calls createHookPromise and appends a second round of async work
// to the promise queue) to propagate before we re-check the queue.
() => new Promise<void>((resolve) => setTimeout(resolve, 0))
)
.then(() => this.getPromiseQueue())
.then(() => {
.then(() => {
// If a newer subscribe() has already invalidated this check, bail out
// before scheduling the extra yield timer.
if (this.unconsumedCheckVersion !== checkVersion) {
return;
}
// Yield to the event loop after the first queue drain. This allows
// microtask chains triggered by the preceding resolve() (e.g., a
// step result delivery that resumes a for-await loop, which then
// calls createHookPromise and appends a second round of async work
// to the promise queue) to propagate before we re-check the queue.
return new Promise<void>((resolve) => setTimeout(resolve, 0));
})
.then(() => {
// Short-circuit stale checks before performing a second queue drain.
if (this.unconsumedCheckVersion !== checkVersion) {
return;
}
return this.getPromiseQueue();
})
.then(() => {
// If a later subscribe() has invalidated this check by the time both
// queue drains (and the yield) have completed, do not schedule the
// final timeout at all.
if (this.unconsumedCheckVersion !== checkVersion) {
return;
}

Copilot uses AI. Check for mistakes.
Comment on lines +639 to +646
const ctx = setupWorkflowContext([
{
eventId: 'evnt_0',
runId: 'wrun_test',
eventType: 'hook_created',
correlationId: `hook_${CORR_IDS[0]}`,
eventData: { token: 'test-token', isWebhook: false },
createdAt: new Date(),
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

This test is intended to ensure an "unconsumed event" error does not occur, but setupWorkflowContext() configures EventsConsumer with onUnconsumedEvent: () => {}. That means the regression would manifest as a hang until the test times out (and it won’t surface the same error the real runtime throws). To make the regression signal deterministic and match production, consider letting the test pass an onUnconsumedEvent handler that rejects via ctx.onWorkflowError (or throws) so a failure is immediate and clearly attributed to the unconsumed-event path.

Copilot uses AI. Check for mistakes.
@pranaygp pranaygp marked this pull request as draft March 27, 2026 18:19
@VaguelySerious
Copy link
Copy Markdown
Member

Double checked this with an agent. I'm adding another e2e test to this PR and then will attempt to ship

Copy link
Copy Markdown
Member

@TooTallNate TooTallNate left a comment

Choose a reason for hiding this comment

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

Review

Good intent — adding multiple angles of regression coverage for the fix from #1778. The e2e test and the test-harness fix in hook-sleep-interaction.test.ts are particularly valuable. I have one blocking issue and some observations.

Blocking

The new test in workflow.test.ts imports DEFERRED_CHECK_DELAY_MS from ./events-consumer.js, but that export doesn't exist (neither on main nor on this branch). The "add more tests" commit (4701796) introduced this export, but the "WIP undo" commit (06a3f42) reverted the events-consumer.ts changes and left the test dangling.

At runtime, DEFERRED_CHECK_DELAY_MS is undefined, so DEFERRED_CHECK_DELAY_MS + 50 is NaN, and setTimeout(r, NaN) coerces to setTimeout(r, 0). The test passes, but it's not actually exercising the case it claims to — "hydrate latency exceeds the deferred-check window." It's running the happy path with near-zero hydrate delay.

See inline comment for fix options.

Non-blocking observations

  1. hook-sleep-interaction.test.ts harness fix is the most valuable change in this PR. The prior onUnconsumedEvent: () => {} silently swallowed errors, meaning any existing test in that file that triggered this error would have silently passed. Wiring it through ctx.onWorkflowError means existing tests now actually catch false-positive unconsumed events. This is a meaningful test infrastructure improvement.

  2. e2e test is good — verifies the fix through real queue/world infrastructure, not just unit-level mocks. The 5s + 3s sleeps between operations are necessary for the replay timing but slightly fragile; worth monitoring for flakes.

  3. Overlap with #1778's test: the existing test in #1778 already covers the alternating hook_received + step-lifecycle pattern with 150ms hydrate delay on call #3. The new hook-sleep-interaction.test.ts test covers similar territory but at the orchestrator-context level rather than runWorkflow level — a useful lower-level variant. Not duplicative.

Comment thread packages/core/src/workflow.test.ts Outdated
// production this corresponds to slower-than-expected encrypted payload
// decryption (cold cache, contended CPU, etc.); the fix must not rely on
// hydrate completing within the timer window.
const hydrateDelayMs = DEFERRED_CHECK_DELAY_MS + 50;
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.

Blocking: DEFERRED_CHECK_DELAY_MS is imported but doesn't exist, so this test isn't actually exercising slow hydrate.

  • Line 6 imports DEFERRED_CHECK_DELAY_MS from ./events-consumer.js
  • events-consumer.ts on this branch (and on main) does not export DEFERRED_CHECK_DELAY_MS — the 100ms value is an inline magic number at events-consumer.ts:141
  • At runtime: DEFERRED_CHECK_DELAY_MS is undefined, undefined + 50 = NaN, setTimeout(r, NaN) behaves as setTimeout(r, 0)
  • Net effect: the test claims to mock hydrate with > 100ms delay but actually mocks it with 0ms delay

So this test runs, passes, but isn't testing what the comment claims. The "WIP undo" commit removed the DEFERRED_CHECK_DELAY_MS export from events-consumer.ts (added in the "add more tests" commit) but left the import here.

Fix options:

  1. Re-export DEFERRED_CHECK_DELAY_MS from events-consumer.ts — this is the cleanest and also improves the production code by replacing the magic 100 at events-consumer.ts:141 with a named constant. Since the fix already shipped in fix false-positive unconsumed event in hook loop replay #1778, this would be a small follow-up enhancement worth including in this test-only PR.

  2. Hardcode the delay — e.g. const hydrateDelayMs = 150. Simplest, but couples the test to an implementation constant.

Option 1 is better. Recommend adding back:

// packages/core/src/events-consumer.ts
export const DEFERRED_CHECK_DELAY_MS = 100;
// ...
this.pendingUnconsumedTimeout = setTimeout(() => {
  // ...
}, DEFERRED_CHECK_DELAY_MS);

Copy link
Copy Markdown
Member

@TooTallNate TooTallNate left a comment

Choose a reason for hiding this comment

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

Blocking issue from prior review is resolved. The 'fix test' commit (5279e839) replaces the phantom DEFERRED_CHECK_DELAY_MS import with local constants:

const DEFFERED_CHECK_DELAY_MS = 100;
const BUFFER_FOR_TEST = 50;
const hydrateDelayMs = DEFFERED_CHECK_DELAY_MS + BUFFER_FOR_TEST;  // 150ms

hydrateDelayMs is now a real 150, which exceeds the actual 100ms deferred-check window hardcoded in events-consumer.ts:141. The test genuinely exercises the slow-hydrate race condition now.

Minor nit (non-blocking): DEFFERED is misspelled twice — should be DEFERRED. Worth fixing while you're in there. If/when the constant is eventually promoted to a proper export in events-consumer.ts (my earlier preferred option), the test can swap these locals out.

Otherwise LGTM — the test harness improvement in hook-sleep-interaction.test.ts remains the most valuable piece here, and the e2e test plus the additional workflow.test.ts case give good coverage of the race from multiple angles.

…e conditions

Fixes a false-positive unconsumed event during replay of a
`for await (const payload of hook) { await step() }` pattern.

The EventsConsumer could advance to a step_created event before the
workflow code registered the step consumer. The previous deferred
unconsumed check chained onto the promise queue once and waited 100ms,
but missed a second round of async work (hook payload deserialization)
triggered by the first drain's resolve().

Fix: after the initial queue drain, yield to the event loop (setTimeout(0))
so microtask chains propagate (e.g., step resolve → for-await resumes →
createHookPromise → new deserialization), then re-chain onto the latest
queue before starting the 100ms timeout.

Adds regression tests across workflow.test.ts, hook-sleep-interaction.test.ts,
e2e.test.ts, and a new workbench example to cover hook/sleep/step race
conditions.

Co-Authored-By: Pranay Prakash <pranay.gp@gmail.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <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.

4 participants