Skip to content

fix(core): detect and fatal error on orphaned/invalid events#1055

Merged
pranaygp merged 9 commits into
mainfrom
pgp/wait-edge-case-check
Feb 14, 2026
Merged

fix(core): detect and fatal error on orphaned/invalid events#1055
pranaygp merged 9 commits into
mainfrom
pgp/wait-edge-case-check

Conversation

@pranaygp
Copy link
Copy Markdown
Contributor

@pranaygp pranaygp commented Feb 13, 2026

Summary

  • When the event log contains duplicate or orphaned events (e.g., 2 wait_completed for a single wait_created), the EventsConsumer previously got stuck — the orphaned event had no callback to consume it, so eventIndex never advanced, blocking all subsequent events and hanging the workflow forever
  • Adds deferred orphaned event detection to EventsConsumer — when a non-null event cannot be consumed by any registered callback, a WorkflowRuntimeError is raised instead of silently hanging
  • Uses setTimeout(0) (macrotask) deferral with cancellation on new subscribes, so legitimate callbacks that register via process.nextTick aren't falsely flagged
  • Adds the CORRUPTED_EVENT_LOG error slug to @workflow/errors with a docs page at /docs/errors/corrupted-event-log explaining causes and remediation

Test plan

  • Updated existing "should hang when duplicate wait_completed" unit test to verify WorkflowRuntimeError is raised via onWorkflowError
  • Added EventsConsumer unit tests: orphaned non-null event calls onUnconsumedEvent, null event does not, backward compat without callback, new subscribe cancels pending check
  • Updated "should not hang when duplicate wait_completed" integration test to expect WorkflowRuntimeError rejection
  • Added integration tests: duplicate step_completed, orphaned step_completed (unknown correlationId), orphaned wait_completed — all blocking subsequent events
  • All 353 core tests pass

🤖 Generated with Claude Code

…sConsumer

When an event log has duplicate or invalid events (e.g., 2 wait_completed for a single wait_created), the EventsConsumer gets stuck: the orphaned event has no callback to consume it, so eventIndex never advances, blocking all subsequent events and hanging the workflow forever. This adds deferred orphaned event detection that raises a WorkflowRuntimeError instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 13, 2026 23:57
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Feb 13, 2026

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 13, 2026

🦋 Changeset detected

Latest commit: 9bfe214

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

This PR includes changesets to release 18 packages
Name Type
@workflow/core Patch
@workflow/errors Patch
@workflow/builders Patch
@workflow/cli Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/web-shared Patch
workflow Patch
@workflow/world-local Patch
@workflow/world-postgres Patch
@workflow/world-vercel Patch
@workflow/astro Patch
@workflow/nest Patch
@workflow/rollup Patch
@workflow/sveltekit Patch
@workflow/vite Patch
@workflow/world-testing Patch
@workflow/nuxt 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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 13, 2026

🧪 E2E Test Results

Some tests failed

Summary

Passed Failed Skipped Total
✅ ▲ Vercel Production 512 0 38 550
✅ 💻 Local Development 532 0 68 600
✅ 📦 Local Production 532 0 68 600
✅ 🐘 Local Postgres 532 0 68 600
✅ 🪟 Windows 47 0 3 50
❌ 🌍 Community Worlds 107 43 9 159
✅ 📋 Other 129 0 21 150
Total 2391 43 275 2709

❌ Failed Tests

🌍 Community Worlds (43 failed)

turso (43 failed):

  • addTenWorkflow
  • addTenWorkflow
  • should work with react rendering in step
  • promiseAllWorkflow
  • promiseRaceWorkflow
  • promiseAnyWorkflow
  • hookWorkflow
  • webhookWorkflow
  • sleepingWorkflow
  • parallelSleepWorkflow
  • nullByteWorkflow
  • workflowAndStepMetadataWorkflow
  • fetchWorkflow
  • promiseRaceStressTestWorkflow
  • 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 retry behavior workflow completes despite transient 5xx on step_completed
  • error handling catchability FatalError can be caught and detected with FatalError.is()
  • hookCleanupTestWorkflow - hook token reuse after workflow completion
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously
  • stepFunctionPassingWorkflow - step function references can be passed as arguments (without closure vars)
  • stepFunctionWithClosureWorkflow - step function with closure variables passed as argument
  • closureVariableWorkflow - nested step functions with closure variables
  • spawnWorkflowFromStepWorkflow - spawning a child workflow using start() inside a step
  • health check (queue-based) - workflow and step endpoints respond to health check messages
  • pathsAliasWorkflow - TypeScript path aliases resolve correctly
  • Calculator.calculate - static workflow method using static step methods from another class
  • AllInOneService.processNumber - static workflow method using sibling static step methods
  • ChainableService.processWithThis - static step methods using this to reference the class
  • thisSerializationWorkflow - step function invoked with .call() and .apply()
  • customSerializationWorkflow - custom class serialization with WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZE
  • instanceMethodStepWorkflow - instance methods with "use step" directive
  • crossContextSerdeWorkflow - classes defined in step code are deserializable in workflow context
  • stepFunctionAsStartArgWorkflow - step function reference passed as start() argument
  • pages router addTenWorkflow via pages router
  • pages router promiseAllWorkflow via pages router
  • pages router sleepingWorkflow via pages router

Details by Category

✅ ▲ Vercel Production
App Passed Failed Skipped
✅ astro 46 0 4
✅ example 46 0 4
✅ express 46 0 4
✅ fastify 46 0 4
✅ hono 46 0 4
✅ nextjs-turbopack 49 0 1
✅ nextjs-webpack 49 0 1
✅ nitro 46 0 4
✅ nuxt 46 0 4
✅ sveltekit 46 0 4
✅ vite 46 0 4
✅ 💻 Local Development
App Passed Failed Skipped
✅ astro-stable 43 0 7
✅ express-stable 43 0 7
✅ fastify-stable 43 0 7
✅ hono-stable 43 0 7
✅ nextjs-turbopack-canary 47 0 3
✅ nextjs-turbopack-stable 47 0 3
✅ nextjs-webpack-canary 47 0 3
✅ nextjs-webpack-stable 47 0 3
✅ nitro-stable 43 0 7
✅ nuxt-stable 43 0 7
✅ sveltekit-stable 43 0 7
✅ vite-stable 43 0 7
✅ 📦 Local Production
App Passed Failed Skipped
✅ astro-stable 43 0 7
✅ express-stable 43 0 7
✅ fastify-stable 43 0 7
✅ hono-stable 43 0 7
✅ nextjs-turbopack-canary 47 0 3
✅ nextjs-turbopack-stable 47 0 3
✅ nextjs-webpack-canary 47 0 3
✅ nextjs-webpack-stable 47 0 3
✅ nitro-stable 43 0 7
✅ nuxt-stable 43 0 7
✅ sveltekit-stable 43 0 7
✅ vite-stable 43 0 7
✅ 🐘 Local Postgres
App Passed Failed Skipped
✅ astro-stable 43 0 7
✅ express-stable 43 0 7
✅ fastify-stable 43 0 7
✅ hono-stable 43 0 7
✅ nextjs-turbopack-canary 47 0 3
✅ nextjs-turbopack-stable 47 0 3
✅ nextjs-webpack-canary 47 0 3
✅ nextjs-webpack-stable 47 0 3
✅ nitro-stable 43 0 7
✅ nuxt-stable 43 0 7
✅ sveltekit-stable 43 0 7
✅ vite-stable 43 0 7
✅ 🪟 Windows
App Passed Failed Skipped
✅ nextjs-turbopack 47 0 3
❌ 🌍 Community Worlds
App Passed Failed Skipped
✅ mongodb-dev 3 0 0
✅ mongodb 47 0 3
✅ redis-dev 3 0 0
✅ redis 47 0 3
✅ turso-dev 3 0 0
❌ turso 4 43 3
✅ 📋 Other
App Passed Failed Skipped
✅ e2e-local-dev-nest-stable 43 0 7
✅ e2e-local-postgres-nest-stable 43 0 7
✅ e2e-local-prod-nest-stable 43 0 7

📋 View full workflow run

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 13, 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.026s (-22.8% 🟢) 1.005s (~) 0.979s 10 1.00x
💻 Local Express 0.031s (-3.4%) 1.004s (~) 0.973s 10 1.20x
💻 Local Next.js (Turbopack) 0.039s 1.006s 0.967s 10 1.48x
🌐 Redis Next.js (Turbopack) 0.048s 1.005s 0.957s 10 1.84x
🌐 MongoDB Next.js (Turbopack) 0.088s 1.007s 0.919s 10 3.40x
🐘 Postgres Express 0.105s (-8.1% 🟢) 1.009s (~) 0.904s 10 4.06x
🐘 Postgres Nitro 0.479s (~) 1.009s (~) 0.530s 10 18.42x
🐘 Postgres Next.js (Turbopack) 0.493s 1.010s 0.517s 10 18.97x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 0.582s (+10.0% 🔺) 1.972s (+14.7% 🔺) 1.390s 10 1.00x
▲ Vercel Express 0.604s (~) 2.120s (+1.0%) 1.516s 10 1.04x
▲ Vercel Next.js (Turbopack) 0.637s (-15.7% 🟢) 2.191s (-0.7%) 1.554s 10 1.10x

🔍 Observability: Nitro | Express | Next.js (Turbopack)

workflow with 1 step

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Nitro 1.072s (-3.2%) 2.005s (~) 0.933s 10 1.00x
💻 Local Next.js (Turbopack) 1.086s 2.005s 0.920s 10 1.01x
🌐 Redis Next.js (Turbopack) 1.100s 2.006s 0.906s 10 1.03x
💻 Local Express 1.105s (~) 2.005s (~) 0.900s 10 1.03x
🌐 MongoDB Next.js (Turbopack) 1.305s 2.008s 0.703s 10 1.22x
🐘 Postgres Next.js (Turbopack) 2.270s 2.813s 0.543s 10 2.12x
🐘 Postgres Nitro 2.354s (~) 3.014s (~) 0.659s 10 2.20x
🐘 Postgres Express 2.492s (+25.5% 🔺) 3.013s (+24.9% 🔺) 0.521s 10 2.33x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 2.232s (-18.2% 🟢) 2.848s (-19.7% 🟢) 0.616s 10 1.00x
▲ Vercel Express 2.283s (-54.2% 🟢) 3.327s (-45.2% 🟢) 1.044s 10 1.02x
▲ Vercel Next.js (Turbopack) 2.377s (-54.2% 🟢) 3.234s (-49.2% 🟢) 0.857s 10 1.06x

🔍 Observability: Nitro | Express | Next.js (Turbopack)

workflow with 10 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Nitro 10.551s (-2.5%) 11.023s (~) 0.472s 3 1.00x
💻 Local Next.js (Turbopack) 10.651s 11.022s 0.371s 3 1.01x
🌐 Redis Next.js (Turbopack) 10.739s 11.022s 0.283s 3 1.02x
💻 Local Express 10.824s (~) 11.022s (~) 0.198s 3 1.03x
🌐 MongoDB Next.js (Turbopack) 12.306s 13.024s 0.718s 3 1.17x
🐘 Postgres Next.js (Turbopack) 15.242s 16.046s 0.804s 2 1.44x
🐘 Postgres Nitro 20.210s (~) 21.056s (~) 0.846s 2 1.92x
🐘 Postgres Express 20.376s (+32.6% 🔺) 21.057s (+31.2% 🔺) 0.681s 2 1.93x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 16.978s (-1.4%) 17.871s (~) 0.893s 2 1.00x
▲ Vercel Express 17.579s (-2.9%) 18.868s (-2.7%) 1.289s 2 1.04x
▲ Vercel Next.js (Turbopack) 17.705s (+1.3%) 18.855s (~) 1.150s 2 1.04x

🔍 Observability: Nitro | Express | Next.js (Turbopack)

workflow with 25 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Nitro 26.775s (-2.7%) 27.052s (-3.6%) 0.277s 3 1.00x
🌐 Redis Next.js (Turbopack) 26.858s 27.050s 0.192s 3 1.00x
💻 Local Next.js (Turbopack) 27.007s 27.049s 0.042s 3 1.01x
💻 Local Express 27.474s (~) 28.051s (~) 0.577s 3 1.03x
🌐 MongoDB Next.js (Turbopack) 30.506s 31.042s 0.536s 2 1.14x
🐘 Postgres Next.js (Turbopack) 37.629s 38.093s 0.464s 2 1.41x
🐘 Postgres Express 50.226s (+33.2% 🔺) 51.131s (+34.2% 🔺) 0.905s 2 1.88x
🐘 Postgres Nitro 50.492s (+11.0% 🔺) 51.126s (+10.9% 🔺) 0.634s 2 1.89x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 44.103s (+0.5%) 45.512s (+1.5%) 1.409s 2 1.00x
▲ Vercel Express 45.438s (+5.7% 🔺) 46.786s (+4.6%) 1.348s 2 1.03x
▲ Vercel Nitro 48.197s (+2.2%) 49.197s (+2.3%) 0.999s 2 1.09x

🔍 Observability: Next.js (Turbopack) | Express | Nitro

workflow with 50 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 54.359s 55.096s 0.737s 2 1.00x
💻 Local Nitro 55.645s (-3.1%) 56.101s (-3.4%) 0.455s 2 1.02x
💻 Local Next.js (Turbopack) 56.337s 57.101s 0.764s 2 1.04x
💻 Local Express 57.272s (~) 58.103s (~) 0.831s 2 1.05x
🌐 MongoDB Next.js (Turbopack) 60.993s 61.067s 0.074s 2 1.12x
🐘 Postgres Next.js (Turbopack) 76.103s 76.683s 0.580s 2 1.40x
🐘 Postgres Nitro 100.155s (+31.5% 🔺) 100.214s (+30.7% 🔺) 0.059s 1 1.84x
🐘 Postgres Express 100.463s (+21.3% 🔺) 101.232s (+20.9% 🔺) 0.769s 1 1.85x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 90.127s (+0.7%) 90.819s (~) 0.692s 1 1.00x
▲ Vercel Next.js (Turbopack) 90.426s (~) 91.209s (~) 0.783s 1 1.00x
▲ Vercel Nitro 90.428s (+2.2%) 91.592s (+2.4%) 1.164s 2 1.00x

🔍 Observability: Express | Next.js (Turbopack) | Nitro

Promise.all with 10 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 1.241s 2.006s 0.765s 15 1.00x
💻 Local Nitro 1.347s (-4.4%) 2.005s (~) 0.658s 15 1.09x
💻 Local Next.js (Turbopack) 1.390s 2.005s 0.616s 15 1.12x
💻 Local Express 1.409s (-1.3%) 2.006s (~) 0.597s 15 1.14x
🌐 MongoDB Next.js (Turbopack) 2.139s 3.008s 0.869s 10 1.72x
🐘 Postgres Next.js (Turbopack) 2.152s 3.014s 0.862s 10 1.73x
🐘 Postgres Nitro 2.170s (+12.1% 🔺) 2.679s (~) 0.510s 12 1.75x
🐘 Postgres Express 2.493s (+2.4%) 3.013s (~) 0.520s 10 2.01x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 2.461s (~) 3.468s (+5.4% 🔺) 1.007s 9 1.00x
▲ Vercel Express 2.718s (+8.9% 🔺) 3.852s (+8.5% 🔺) 1.133s 8 1.10x
▲ Vercel Next.js (Turbopack) 3.021s (-12.3% 🟢) 4.174s (-5.5% 🟢) 1.153s 8 1.23x

🔍 Observability: Nitro | Express | Next.js (Turbopack)

Promise.all with 25 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Nitro 2.278s (-13.0% 🟢) 3.007s (~) 0.728s 10 1.00x
💻 Local Next.js (Turbopack) 2.406s 3.007s 0.601s 10 1.06x
🌐 Redis Next.js (Turbopack) 2.486s 3.008s 0.522s 10 1.09x
💻 Local Express 2.570s (-2.6%) 3.008s (~) 0.438s 10 1.13x
🌐 MongoDB Next.js (Turbopack) 4.706s 5.177s 0.471s 6 2.07x
🐘 Postgres Express 7.952s (-15.1% 🟢) 8.527s (-15.0% 🟢) 0.576s 4 3.49x
🐘 Postgres Nitro 10.828s (+12.2% 🔺) 11.034s (+10.0% 🔺) 0.206s 3 4.75x
🐘 Postgres Next.js (Turbopack) 11.555s 12.033s 0.478s 3 5.07x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 2.935s (+6.4% 🔺) 3.496s (-3.0%) 0.561s 9 1.00x
▲ Vercel Next.js (Turbopack) 2.946s (-19.9% 🟢) 3.697s (-19.4% 🟢) 0.751s 9 1.00x
▲ Vercel Express 4.071s (+44.0% 🔺) 5.217s (+29.8% 🔺) 1.146s 6 1.39x

🔍 Observability: Nitro | Next.js (Turbopack) | Express

Promise.all with 50 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 4.088s 4.582s 0.494s 7 1.00x
💻 Local Nitro 6.301s (-18.7% 🟢) 7.014s (-12.5% 🟢) 0.713s 5 1.54x
💻 Local Next.js (Turbopack) 6.918s 7.515s 0.597s 4 1.69x
💻 Local Express 7.310s (-5.0%) 8.018s (~) 0.708s 4 1.79x
🌐 MongoDB Next.js (Turbopack) 9.735s 10.348s 0.613s 3 2.38x
🐘 Postgres Express 48.561s (+5.3% 🔺) 49.117s (+4.2%) 0.556s 1 11.88x
🐘 Postgres Nitro 49.528s (+1.5%) 50.127s (+2.0%) 0.599s 1 12.12x
🐘 Postgres Next.js (Turbopack) 50.695s 51.116s 0.421s 1 12.40x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 3.161s (-12.3% 🟢) 4.394s (-10.0% 🟢) 1.233s 7 1.00x
▲ Vercel Next.js (Turbopack) 4.520s (+18.0% 🔺) 5.941s (+15.7% 🔺) 1.421s 6 1.43x
▲ Vercel Express 4.594s (+13.7% 🔺) 5.580s (+7.6% 🔺) 0.986s 6 1.45x

🔍 Observability: Nitro | Next.js (Turbopack) | Express

Promise.race with 10 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 1.257s 2.006s 0.749s 15 1.00x
💻 Local Nitro 1.383s (-4.4%) 2.005s (~) 0.622s 15 1.10x
💻 Local Express 1.411s (-2.1%) 2.006s (~) 0.595s 15 1.12x
💻 Local Next.js (Turbopack) 1.418s 2.006s 0.588s 15 1.13x
🐘 Postgres Nitro 1.795s (-18.2% 🟢) 2.011s (-22.6% 🟢) 0.216s 15 1.43x
🐘 Postgres Express 2.016s (-8.8% 🟢) 2.513s (-6.3% 🟢) 0.498s 12 1.60x
🌐 MongoDB Next.js (Turbopack) 2.156s 3.007s 0.851s 10 1.71x
🐘 Postgres Next.js (Turbopack) 2.205s 2.596s 0.391s 12 1.75x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 2.376s (+4.4%) 3.652s (+12.3% 🔺) 1.276s 9 1.00x
▲ Vercel Nitro 2.423s (+2.8%) 3.465s (+5.7% 🔺) 1.042s 9 1.02x
▲ Vercel Express 2.466s (-0.8%) 3.460s (-3.6%) 0.994s 9 1.04x

🔍 Observability: Next.js (Turbopack) | Nitro | Express

Promise.race with 25 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Nitro 2.392s (-13.5% 🟢) 3.008s (~) 0.616s 10 1.00x
🌐 Redis Next.js (Turbopack) 2.500s 3.008s 0.508s 10 1.05x
💻 Local Next.js (Turbopack) 2.547s 3.008s 0.460s 10 1.07x
💻 Local Express 2.684s (-3.1%) 3.007s (~) 0.323s 10 1.12x
🌐 MongoDB Next.js (Turbopack) 4.678s 5.177s 0.499s 6 1.96x
🐘 Postgres Nitro 11.136s (+1.0%) 11.703s (+2.9%) 0.567s 3 4.66x
🐘 Postgres Express 11.259s (-9.2% 🟢) 11.697s (-10.3% 🟢) 0.438s 3 4.71x
🐘 Postgres Next.js (Turbopack) 11.602s 12.365s 0.763s 3 4.85x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 2.466s (+0.6%) 3.089s (-9.5% 🟢) 0.623s 10 1.00x
▲ Vercel Next.js (Turbopack) 2.614s (+0.9%) 4.004s (+11.6% 🔺) 1.390s 8 1.06x
▲ Vercel Express 3.000s (-15.7% 🟢) 3.939s (-14.3% 🟢) 0.940s 8 1.22x

🔍 Observability: Nitro | Next.js (Turbopack) | Express

Promise.race with 50 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 4.078s 4.724s 0.646s 7 1.00x
💻 Local Next.js (Turbopack) 6.732s 7.213s 0.480s 5 1.65x
💻 Local Nitro 7.004s (-13.0% 🟢) 7.515s (-11.8% 🟢) 0.511s 4 1.72x
💻 Local Express 7.962s (-2.5%) 8.519s (-5.6% 🟢) 0.557s 4 1.95x
🌐 MongoDB Next.js (Turbopack) 9.845s 10.347s 0.502s 3 2.41x
🐘 Postgres Nitro 51.308s (+5.8% 🔺) 52.116s (+6.1% 🔺) 0.808s 1 12.58x
🐘 Postgres Express 51.596s (+2.2%) 52.124s (+2.0%) 0.528s 1 12.65x
🐘 Postgres Next.js (Turbopack) 53.052s 53.112s 0.060s 1 13.01x

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 3.070s (-25.8% 🟢) 3.981s (-21.3% 🟢) 0.911s 8 1.00x
▲ Vercel Nitro 3.728s (+13.0% 🔺) 4.929s (+5.5% 🔺) 1.201s 7 1.21x
▲ Vercel Next.js (Turbopack) 3.910s (-17.0% 🟢) 5.060s (-16.6% 🟢) 1.149s 6 1.27x

🔍 Observability: Express | Nitro | 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.111s (-37.2% 🟢) 1.002s (~) 0.009s (-22.5% 🟢) 1.014s (~) 0.903s 10 1.00x
💻 Local Next.js (Turbopack) 0.119s 1.001s 0.010s 1.016s 0.897s 10 1.07x
🌐 Redis Next.js (Turbopack) 0.146s 1.000s 0.001s 1.007s 0.861s 10 1.31x
💻 Local Express 0.172s (~) 1.002s (~) 0.011s (-8.3% 🟢) 1.016s (~) 0.844s 10 1.55x
🌐 MongoDB Next.js (Turbopack) 0.492s 0.953s 0.002s 1.008s 0.516s 10 4.43x
🐘 Postgres Next.js (Turbopack) 1.435s 1.625s 0.001s 2.013s 0.578s 10 12.92x
🐘 Postgres Express 2.224s (+61.8% 🔺) 2.818s (+69.3% 🔺) 0.001s (-6.7% 🟢) 3.015s (+49.8% 🔺) 0.791s 10 20.02x
🐘 Postgres Nitro 2.286s (+82.0% 🔺) 2.748s (+48.2% 🔺) 0.001s (-14.3% 🟢) 3.014s (+49.7% 🔺) 0.728s 10 20.58x

▲ Production (Vercel)

World Framework Workflow Time TTFB Slurp Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 2.006s (-9.5% 🟢) 2.652s (-10.0% 🟢) 0.437s (+110.4% 🔺) 3.667s (-1.7%) 1.661s 10 1.00x
▲ Vercel Express 2.147s (-11.8% 🟢) 2.782s (-6.1% 🟢) 0.242s (+15.2% 🔺) 3.673s (-2.5%) 1.526s 10 1.07x
▲ Vercel Nitro 2.311s (+12.2% 🔺) 2.586s (+8.1% 🔺) 0.254s (+0.8%) 3.467s (+7.7% 🔺) 1.157s 10 1.15x

🔍 Observability: Next.js (Turbopack) | Express | Nitro

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World 🥇 Fastest Framework Wins
💻 Local Nitro 11/12
🐘 Postgres Next.js (Turbopack) 6/12
▲ Vercel Nitro 7/12
Fastest World by Framework

Winner determined by most benchmark wins

Framework 🥇 Fastest World Wins
Express 💻 Local 10/12
Next.js (Turbopack) 🌐 Redis 6/12
Nitro 💻 Local 10/12
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

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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

This PR adds detection and error handling for orphaned/invalid events in the workflow event log that would otherwise cause workflows to hang silently. The implementation uses a deferred detection mechanism with setTimeout(0) to allow legitimate callbacks registered via process.nextTick to complete before flagging an event as orphaned.

Changes:

  • Added onUnconsumedEvent callback parameter to EventsConsumer that triggers when events cannot be consumed
  • Wired orphaned event detection in runWorkflow to reject the workflow with WorkflowRuntimeError
  • Added comprehensive unit and integration tests for duplicate and orphaned events across wait and step operations

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/core/src/events-consumer.ts Implements deferred orphaned event detection using setTimeout(0) with cancellation on new subscribes
packages/core/src/events-consumer.test.ts Adds unit tests for onUnconsumedEvent callback covering null events, orphaned events, and subscribe cancellation
packages/core/src/workflow.ts Wires EventsConsumer with onUnconsumedEvent callback that rejects workflow via workflowDiscontinuation
packages/core/src/workflow.test.ts Adds integration tests for duplicate wait_completed, duplicate step_completed, and orphaned events blocking workflow execution
packages/core/src/workflow/sleep.test.ts Updates setupWorkflowContext helper with onUnconsumedEvent handler and adds test for duplicate wait_completed events

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

Comment thread packages/core/src/events-consumer.ts Outdated
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use correct imports (getRun from workflow/api) and declare variables
to satisfy the docs-typecheck CI job.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

I think it'd be great to have an e2e test that does Promise.all([10x sleep('1s')]) or similar and asserts any status return within ~2s (since it might fail or not).

Adds parallelSleepWorkflow that does Promise.all with 10 concurrent
sleep('1s') calls, and an e2e test asserting it completes or fails
within a reasonable time (not hanging).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pranaygp
Copy link
Copy Markdown
Contributor Author

Added in 678901dparallelSleepWorkflow does Promise.all(Array.from({ length: 10 }, () => sleep('1s'))) and the e2e test asserts it reaches a terminal status (completed or failed) within 60s.

pranaygp and others added 2 commits February 13, 2026 20:18
run.status returns immediately and the workflow is still 'running'.
Use run.returnValue which polls until completion.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The test verifies 10 concurrent sleep('1s') calls complete in parallel
(~1s) rather than serially (10s) or hanging indefinitely. 30s timeout
is sufficient since the workflow should finish in ~1-2s.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@TooTallNate
Copy link
Copy Markdown
Member

Code Review

The orphaned event detection is a solid improvement — turning a silent hang into a fast, diagnosable failure is the right call. The setTimeout(0) macrotask deferral with cancellation on new subscribes is a clever approach to avoid false positives from legitimate callbacks that register via process.nextTick. A few things to flag:

The setTimeout(0) Timing Assumption

The core assumption is that all legitimate callbacks will subscribe() via process.nextTick microtasks, and that a setTimeout(0) macrotask fires after all of them. This is correct for Node.js's event loop ordering (microtasks before macrotasks), but it's worth noting this is a timing-based heuristic, not a structural guarantee. If any future code path registers a callback asynchronously (e.g., after an await or I/O), it would race with the macrotask timeout.

That said, the current workflow code does register callbacks synchronously during replay, so this is safe today. The cancellation-on-subscribe mechanism provides a good safety net.

Docs Quality

The corrupted-event-log.mdx docs page is well-written. It correctly frames this as an SDK/server bug rather than a user code issue, which is important for user trust. The remediation steps (upgrade, retry, report) are practical.

Test Coverage

Good coverage of the key scenarios:

  • Duplicate wait_completed and step_completed events
  • Orphaned events with unknown correlationId
  • Null event (end-of-events) correctly not triggering the callback
  • New subscribe cancelling a pending check

The parallel sleep e2e test (parallelSleepWorkflow) is a nice addition for validating real-world concurrency behavior.

Minor Nit

In sleep.test.ts, the setupWorkflowContext helper creates a circular reference (ctx.onWorkflowError used inside the EventsConsumer options which is set on ctx). It works because of the closure, but it's a bit subtle — a comment would help future readers.

Overall this looks good to ship.

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