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

@pranaygppranaygp commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

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>
CopilotAI review requested due to automatic review settings February 13, 2026 23:57
@vercel

vercelBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-botBot commented Feb 13, 2026

Copy link
Copy Markdown

🦋 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
NameType
@workflow/corePatch
@workflow/errorsPatch
@workflow/buildersPatch
@workflow/cliPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/web-sharedPatch
workflowPatch
@workflow/world-localPatch
@workflow/world-postgresPatch
@workflow/world-vercelPatch
@workflow/astroPatch
@workflow/nestPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
@workflow/vitePatch
@workflow/world-testingPatch
@workflow/nuxtPatch

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

github-actionsBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

Some tests failed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production512038550
✅ 💻 Local Development532068600
✅ 📦 Local Production532068600
✅ 🐘 Local Postgres532068600
✅ 🪟 Windows470350
❌ 🌍 Community Worlds107439159
✅ 📋 Other129021150
Total2391432752709

❌ 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
AppPassedFailedSkipped
✅ astro4604
✅ example4604
✅ express4604
✅ fastify4604
✅ hono4604
✅ nextjs-turbopack4901
✅ nextjs-webpack4901
✅ nitro4604
✅ nuxt4604
✅ sveltekit4604
✅ vite4604
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack4703
❌ 🌍 Community Worlds
AppPassedFailedSkipped
✅ mongodb-dev300
✅ mongodb4703
✅ redis-dev300
✅ redis4703
✅ turso-dev300
❌ turso4433
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable4307
✅ e2e-local-postgres-nest-stable4307
✅ e2e-local-prod-nest-stable4307

📋 View full workflow run

@github-actions

github-actionsBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

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

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.026s (-22.8% 🟢)1.005s (~)0.979s101.00x
💻 LocalExpress0.031s (-3.4%)1.004s (~)0.973s101.20x
💻 LocalNext.js (Turbopack)0.039s1.006s0.967s101.48x
🌐 RedisNext.js (Turbopack)0.048s1.005s0.957s101.84x
🌐 MongoDBNext.js (Turbopack)0.088s1.007s0.919s103.40x
🐘 PostgresExpress0.105s (-8.1% 🟢)1.009s (~)0.904s104.06x
🐘 PostgresNitro0.479s (~)1.009s (~)0.530s1018.42x
🐘 PostgresNext.js (Turbopack)0.493s1.010s0.517s1018.97x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro0.582s (+10.0% 🔺)1.972s (+14.7% 🔺)1.390s101.00x
▲ VercelExpress0.604s (~)2.120s (+1.0%)1.516s101.04x
▲ VercelNext.js (Turbopack)0.637s (-15.7% 🟢)2.191s (-0.7%)1.554s101.10x

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

workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro1.072s (-3.2%)2.005s (~)0.933s101.00x
💻 LocalNext.js (Turbopack)1.086s2.005s0.920s101.01x
🌐 RedisNext.js (Turbopack)1.100s2.006s0.906s101.03x
💻 LocalExpress1.105s (~)2.005s (~)0.900s101.03x
🌐 MongoDBNext.js (Turbopack)1.305s2.008s0.703s101.22x
🐘 PostgresNext.js (Turbopack)2.270s2.813s0.543s102.12x
🐘 PostgresNitro2.354s (~)3.014s (~)0.659s102.20x
🐘 PostgresExpress2.492s (+25.5% 🔺)3.013s (+24.9% 🔺)0.521s102.33x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.232s (-18.2% 🟢)2.848s (-19.7% 🟢)0.616s101.00x
▲ VercelExpress2.283s (-54.2% 🟢)3.327s (-45.2% 🟢)1.044s101.02x
▲ VercelNext.js (Turbopack)2.377s (-54.2% 🟢)3.234s (-49.2% 🟢)0.857s101.06x

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

workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro10.551s (-2.5%)11.023s (~)0.472s31.00x
💻 LocalNext.js (Turbopack)10.651s11.022s0.371s31.01x
🌐 RedisNext.js (Turbopack)10.739s11.022s0.283s31.02x
💻 LocalExpress10.824s (~)11.022s (~)0.198s31.03x
🌐 MongoDBNext.js (Turbopack)12.306s13.024s0.718s31.17x
🐘 PostgresNext.js (Turbopack)15.242s16.046s0.804s21.44x
🐘 PostgresNitro20.210s (~)21.056s (~)0.846s21.92x
🐘 PostgresExpress20.376s (+32.6% 🔺)21.057s (+31.2% 🔺)0.681s21.93x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro16.978s (-1.4%)17.871s (~)0.893s21.00x
▲ VercelExpress17.579s (-2.9%)18.868s (-2.7%)1.289s21.04x
▲ VercelNext.js (Turbopack)17.705s (+1.3%)18.855s (~)1.150s21.04x

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

workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro26.775s (-2.7%)27.052s (-3.6%)0.277s31.00x
🌐 RedisNext.js (Turbopack)26.858s27.050s0.192s31.00x
💻 LocalNext.js (Turbopack)27.007s27.049s0.042s31.01x
💻 LocalExpress27.474s (~)28.051s (~)0.577s31.03x
🌐 MongoDBNext.js (Turbopack)30.506s31.042s0.536s21.14x
🐘 PostgresNext.js (Turbopack)37.629s38.093s0.464s21.41x
🐘 PostgresExpress50.226s (+33.2% 🔺)51.131s (+34.2% 🔺)0.905s21.88x
🐘 PostgresNitro50.492s (+11.0% 🔺)51.126s (+10.9% 🔺)0.634s21.89x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)44.103s (+0.5%)45.512s (+1.5%)1.409s21.00x
▲ VercelExpress45.438s (+5.7% 🔺)46.786s (+4.6%)1.348s21.03x
▲ VercelNitro48.197s (+2.2%)49.197s (+2.3%)0.999s21.09x

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

workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)54.359s55.096s0.737s21.00x
💻 LocalNitro55.645s (-3.1%)56.101s (-3.4%)0.455s21.02x
💻 LocalNext.js (Turbopack)56.337s57.101s0.764s21.04x
💻 LocalExpress57.272s (~)58.103s (~)0.831s21.05x
🌐 MongoDBNext.js (Turbopack)60.993s61.067s0.074s21.12x
🐘 PostgresNext.js (Turbopack)76.103s76.683s0.580s21.40x
🐘 PostgresNitro100.155s (+31.5% 🔺)100.214s (+30.7% 🔺)0.059s11.84x
🐘 PostgresExpress100.463s (+21.3% 🔺)101.232s (+20.9% 🔺)0.769s11.85x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express90.127s (+0.7%)90.819s (~)0.692s11.00x
▲ VercelNext.js (Turbopack)90.426s (~)91.209s (~)0.783s11.00x
▲ VercelNitro90.428s (+2.2%)91.592s (+2.4%)1.164s21.00x

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

Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)1.241s2.006s0.765s151.00x
💻 LocalNitro1.347s (-4.4%)2.005s (~)0.658s151.09x
💻 LocalNext.js (Turbopack)1.390s2.005s0.616s151.12x
💻 LocalExpress1.409s (-1.3%)2.006s (~)0.597s151.14x
🌐 MongoDBNext.js (Turbopack)2.139s3.008s0.869s101.72x
🐘 PostgresNext.js (Turbopack)2.152s3.014s0.862s101.73x
🐘 PostgresNitro2.170s (+12.1% 🔺)2.679s (~)0.510s121.75x
🐘 PostgresExpress2.493s (+2.4%)3.013s (~)0.520s102.01x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.461s (~)3.468s (+5.4% 🔺)1.007s91.00x
▲ VercelExpress2.718s (+8.9% 🔺)3.852s (+8.5% 🔺)1.133s81.10x
▲ VercelNext.js (Turbopack)3.021s (-12.3% 🟢)4.174s (-5.5% 🟢)1.153s81.23x

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

Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro2.278s (-13.0% 🟢)3.007s (~)0.728s101.00x
💻 LocalNext.js (Turbopack)2.406s3.007s0.601s101.06x
🌐 RedisNext.js (Turbopack)2.486s3.008s0.522s101.09x
💻 LocalExpress2.570s (-2.6%)3.008s (~)0.438s101.13x
🌐 MongoDBNext.js (Turbopack)4.706s5.177s0.471s62.07x
🐘 PostgresExpress7.952s (-15.1% 🟢)8.527s (-15.0% 🟢)0.576s43.49x
🐘 PostgresNitro10.828s (+12.2% 🔺)11.034s (+10.0% 🔺)0.206s34.75x
🐘 PostgresNext.js (Turbopack)11.555s12.033s0.478s35.07x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.935s (+6.4% 🔺)3.496s (-3.0%)0.561s91.00x
▲ VercelNext.js (Turbopack)2.946s (-19.9% 🟢)3.697s (-19.4% 🟢)0.751s91.00x
▲ VercelExpress4.071s (+44.0% 🔺)5.217s (+29.8% 🔺)1.146s61.39x

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

Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)4.088s4.582s0.494s71.00x
💻 LocalNitro6.301s (-18.7% 🟢)7.014s (-12.5% 🟢)0.713s51.54x
💻 LocalNext.js (Turbopack)6.918s7.515s0.597s41.69x
💻 LocalExpress7.310s (-5.0%)8.018s (~)0.708s41.79x
🌐 MongoDBNext.js (Turbopack)9.735s10.348s0.613s32.38x
🐘 PostgresExpress48.561s (+5.3% 🔺)49.117s (+4.2%)0.556s111.88x
🐘 PostgresNitro49.528s (+1.5%)50.127s (+2.0%)0.599s112.12x
🐘 PostgresNext.js (Turbopack)50.695s51.116s0.421s112.40x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.161s (-12.3% 🟢)4.394s (-10.0% 🟢)1.233s71.00x
▲ VercelNext.js (Turbopack)4.520s (+18.0% 🔺)5.941s (+15.7% 🔺)1.421s61.43x
▲ VercelExpress4.594s (+13.7% 🔺)5.580s (+7.6% 🔺)0.986s61.45x

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

Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)1.257s2.006s0.749s151.00x
💻 LocalNitro1.383s (-4.4%)2.005s (~)0.622s151.10x
💻 LocalExpress1.411s (-2.1%)2.006s (~)0.595s151.12x
💻 LocalNext.js (Turbopack)1.418s2.006s0.588s151.13x
🐘 PostgresNitro1.795s (-18.2% 🟢)2.011s (-22.6% 🟢)0.216s151.43x
🐘 PostgresExpress2.016s (-8.8% 🟢)2.513s (-6.3% 🟢)0.498s121.60x
🌐 MongoDBNext.js (Turbopack)2.156s3.007s0.851s101.71x
🐘 PostgresNext.js (Turbopack)2.205s2.596s0.391s121.75x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)2.376s (+4.4%)3.652s (+12.3% 🔺)1.276s91.00x
▲ VercelNitro2.423s (+2.8%)3.465s (+5.7% 🔺)1.042s91.02x
▲ VercelExpress2.466s (-0.8%)3.460s (-3.6%)0.994s91.04x

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

Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro2.392s (-13.5% 🟢)3.008s (~)0.616s101.00x
🌐 RedisNext.js (Turbopack)2.500s3.008s0.508s101.05x
💻 LocalNext.js (Turbopack)2.547s3.008s0.460s101.07x
💻 LocalExpress2.684s (-3.1%)3.007s (~)0.323s101.12x
🌐 MongoDBNext.js (Turbopack)4.678s5.177s0.499s61.96x
🐘 PostgresNitro11.136s (+1.0%)11.703s (+2.9%)0.567s34.66x
🐘 PostgresExpress11.259s (-9.2% 🟢)11.697s (-10.3% 🟢)0.438s34.71x
🐘 PostgresNext.js (Turbopack)11.602s12.365s0.763s34.85x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.466s (+0.6%)3.089s (-9.5% 🟢)0.623s101.00x
▲ VercelNext.js (Turbopack)2.614s (+0.9%)4.004s (+11.6% 🔺)1.390s81.06x
▲ VercelExpress3.000s (-15.7% 🟢)3.939s (-14.3% 🟢)0.940s81.22x

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

Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)4.078s4.724s0.646s71.00x
💻 LocalNext.js (Turbopack)6.732s7.213s0.480s51.65x
💻 LocalNitro7.004s (-13.0% 🟢)7.515s (-11.8% 🟢)0.511s41.72x
💻 LocalExpress7.962s (-2.5%)8.519s (-5.6% 🟢)0.557s41.95x
🌐 MongoDBNext.js (Turbopack)9.845s10.347s0.502s32.41x
🐘 PostgresNitro51.308s (+5.8% 🔺)52.116s (+6.1% 🔺)0.808s112.58x
🐘 PostgresExpress51.596s (+2.2%)52.124s (+2.0%)0.528s112.65x
🐘 PostgresNext.js (Turbopack)53.052s53.112s0.060s113.01x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express3.070s (-25.8% 🟢)3.981s (-21.3% 🟢)0.911s81.00x
▲ VercelNitro3.728s (+13.0% 🔺)4.929s (+5.5% 🔺)1.201s71.21x
▲ VercelNext.js (Turbopack)3.910s (-17.0% 🟢)5.060s (-16.6% 🟢)1.149s61.27x

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

Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.111s (-37.2% 🟢)1.002s (~)0.009s (-22.5% 🟢)1.014s (~)0.903s101.00x
💻 LocalNext.js (Turbopack)0.119s1.001s0.010s1.016s0.897s101.07x
🌐 RedisNext.js (Turbopack)0.146s1.000s0.001s1.007s0.861s101.31x
💻 LocalExpress0.172s (~)1.002s (~)0.011s (-8.3% 🟢)1.016s (~)0.844s101.55x
🌐 MongoDBNext.js (Turbopack)0.492s0.953s0.002s1.008s0.516s104.43x
🐘 PostgresNext.js (Turbopack)1.435s1.625s0.001s2.013s0.578s1012.92x
🐘 PostgresExpress2.224s (+61.8% 🔺)2.818s (+69.3% 🔺)0.001s (-6.7% 🟢)3.015s (+49.8% 🔺)0.791s1020.02x
🐘 PostgresNitro2.286s (+82.0% 🔺)2.748s (+48.2% 🔺)0.001s (-14.3% 🟢)3.014s (+49.7% 🔺)0.728s1020.58x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)2.006s (-9.5% 🟢)2.652s (-10.0% 🟢)0.437s (+110.4% 🔺)3.667s (-1.7%)1.661s101.00x
▲ VercelExpress2.147s (-11.8% 🟢)2.782s (-6.1% 🟢)0.242s (+15.2% 🔺)3.673s (-2.5%)1.526s101.07x
▲ VercelNitro2.311s (+12.2% 🔺)2.586s (+8.1% 🔺)0.254s (+0.8%)3.467s (+7.7% 🔺)1.157s101.15x

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

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro11/12
🐘 PostgresNext.js (Turbopack)6/12
▲ VercelNitro7/12
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express💻 Local10/12
Next.js (Turbopack)🌐 Redis6/12
Nitro💻 Local10/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>

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
packages/core/src/events-consumer.tsImplements deferred orphaned event detection using setTimeout(0) with cancellation on new subscribes
packages/core/src/events-consumer.test.tsAdds unit tests for onUnconsumedEvent callback covering null events, orphaned events, and subscribe cancellation
packages/core/src/workflow.tsWires EventsConsumer with onUnconsumedEvent callback that rejects workflow via workflowDiscontinuation
packages/core/src/workflow.test.tsAdds integration tests for duplicate wait_completed, duplicate step_completed, and orphaned events blocking workflow execution
packages/core/src/workflow/sleep.test.tsUpdates 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 threadpackages/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>

@VaguelySeriousVaguelySerious left a comment

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.

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
ContributorAuthor

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.

pranaygpand 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 freeto 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

@pranaygp@TooTallNate@VaguelySerious
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
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

@pranaygppranaygp commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

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>
CopilotAI review requested due to automatic review settings February 13, 2026 23:57
@vercel

vercelBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-botBot commented Feb 13, 2026

Copy link
Copy Markdown

🦋 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
NameType
@workflow/corePatch
@workflow/errorsPatch
@workflow/buildersPatch
@workflow/cliPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/web-sharedPatch
workflowPatch
@workflow/world-localPatch
@workflow/world-postgresPatch
@workflow/world-vercelPatch
@workflow/astroPatch
@workflow/nestPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
@workflow/vitePatch
@workflow/world-testingPatch
@workflow/nuxtPatch

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

github-actionsBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

Some tests failed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production512038550
✅ 💻 Local Development532068600
✅ 📦 Local Production532068600
✅ 🐘 Local Postgres532068600
✅ 🪟 Windows470350
❌ 🌍 Community Worlds107439159
✅ 📋 Other129021150
Total2391432752709

❌ 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
AppPassedFailedSkipped
✅ astro4604
✅ example4604
✅ express4604
✅ fastify4604
✅ hono4604
✅ nextjs-turbopack4901
✅ nextjs-webpack4901
✅ nitro4604
✅ nuxt4604
✅ sveltekit4604
✅ vite4604
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack4703
❌ 🌍 Community Worlds
AppPassedFailedSkipped
✅ mongodb-dev300
✅ mongodb4703
✅ redis-dev300
✅ redis4703
✅ turso-dev300
❌ turso4433
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable4307
✅ e2e-local-postgres-nest-stable4307
✅ e2e-local-prod-nest-stable4307

📋 View full workflow run

@github-actions

github-actionsBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

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

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.026s (-22.8% 🟢)1.005s (~)0.979s101.00x
💻 LocalExpress0.031s (-3.4%)1.004s (~)0.973s101.20x
💻 LocalNext.js (Turbopack)0.039s1.006s0.967s101.48x
🌐 RedisNext.js (Turbopack)0.048s1.005s0.957s101.84x
🌐 MongoDBNext.js (Turbopack)0.088s1.007s0.919s103.40x
🐘 PostgresExpress0.105s (-8.1% 🟢)1.009s (~)0.904s104.06x
🐘 PostgresNitro0.479s (~)1.009s (~)0.530s1018.42x
🐘 PostgresNext.js (Turbopack)0.493s1.010s0.517s1018.97x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro0.582s (+10.0% 🔺)1.972s (+14.7% 🔺)1.390s101.00x
▲ VercelExpress0.604s (~)2.120s (+1.0%)1.516s101.04x
▲ VercelNext.js (Turbopack)0.637s (-15.7% 🟢)2.191s (-0.7%)1.554s101.10x

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

workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro1.072s (-3.2%)2.005s (~)0.933s101.00x
💻 LocalNext.js (Turbopack)1.086s2.005s0.920s101.01x
🌐 RedisNext.js (Turbopack)1.100s2.006s0.906s101.03x
💻 LocalExpress1.105s (~)2.005s (~)0.900s101.03x
🌐 MongoDBNext.js (Turbopack)1.305s2.008s0.703s101.22x
🐘 PostgresNext.js (Turbopack)2.270s2.813s0.543s102.12x
🐘 PostgresNitro2.354s (~)3.014s (~)0.659s102.20x
🐘 PostgresExpress2.492s (+25.5% 🔺)3.013s (+24.9% 🔺)0.521s102.33x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.232s (-18.2% 🟢)2.848s (-19.7% 🟢)0.616s101.00x
▲ VercelExpress2.283s (-54.2% 🟢)3.327s (-45.2% 🟢)1.044s101.02x
▲ VercelNext.js (Turbopack)2.377s (-54.2% 🟢)3.234s (-49.2% 🟢)0.857s101.06x

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

workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro10.551s (-2.5%)11.023s (~)0.472s31.00x
💻 LocalNext.js (Turbopack)10.651s11.022s0.371s31.01x
🌐 RedisNext.js (Turbopack)10.739s11.022s0.283s31.02x
💻 LocalExpress10.824s (~)11.022s (~)0.198s31.03x
🌐 MongoDBNext.js (Turbopack)12.306s13.024s0.718s31.17x
🐘 PostgresNext.js (Turbopack)15.242s16.046s0.804s21.44x
🐘 PostgresNitro20.210s (~)21.056s (~)0.846s21.92x
🐘 PostgresExpress20.376s (+32.6% 🔺)21.057s (+31.2% 🔺)0.681s21.93x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro16.978s (-1.4%)17.871s (~)0.893s21.00x
▲ VercelExpress17.579s (-2.9%)18.868s (-2.7%)1.289s21.04x
▲ VercelNext.js (Turbopack)17.705s (+1.3%)18.855s (~)1.150s21.04x

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

workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro26.775s (-2.7%)27.052s (-3.6%)0.277s31.00x
🌐 RedisNext.js (Turbopack)26.858s27.050s0.192s31.00x
💻 LocalNext.js (Turbopack)27.007s27.049s0.042s31.01x
💻 LocalExpress27.474s (~)28.051s (~)0.577s31.03x
🌐 MongoDBNext.js (Turbopack)30.506s31.042s0.536s21.14x
🐘 PostgresNext.js (Turbopack)37.629s38.093s0.464s21.41x
🐘 PostgresExpress50.226s (+33.2% 🔺)51.131s (+34.2% 🔺)0.905s21.88x
🐘 PostgresNitro50.492s (+11.0% 🔺)51.126s (+10.9% 🔺)0.634s21.89x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)44.103s (+0.5%)45.512s (+1.5%)1.409s21.00x
▲ VercelExpress45.438s (+5.7% 🔺)46.786s (+4.6%)1.348s21.03x
▲ VercelNitro48.197s (+2.2%)49.197s (+2.3%)0.999s21.09x

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

workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)54.359s55.096s0.737s21.00x
💻 LocalNitro55.645s (-3.1%)56.101s (-3.4%)0.455s21.02x
💻 LocalNext.js (Turbopack)56.337s57.101s0.764s21.04x
💻 LocalExpress57.272s (~)58.103s (~)0.831s21.05x
🌐 MongoDBNext.js (Turbopack)60.993s61.067s0.074s21.12x
🐘 PostgresNext.js (Turbopack)76.103s76.683s0.580s21.40x
🐘 PostgresNitro100.155s (+31.5% 🔺)100.214s (+30.7% 🔺)0.059s11.84x
🐘 PostgresExpress100.463s (+21.3% 🔺)101.232s (+20.9% 🔺)0.769s11.85x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express90.127s (+0.7%)90.819s (~)0.692s11.00x
▲ VercelNext.js (Turbopack)90.426s (~)91.209s (~)0.783s11.00x
▲ VercelNitro90.428s (+2.2%)91.592s (+2.4%)1.164s21.00x

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

Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)1.241s2.006s0.765s151.00x
💻 LocalNitro1.347s (-4.4%)2.005s (~)0.658s151.09x
💻 LocalNext.js (Turbopack)1.390s2.005s0.616s151.12x
💻 LocalExpress1.409s (-1.3%)2.006s (~)0.597s151.14x
🌐 MongoDBNext.js (Turbopack)2.139s3.008s0.869s101.72x
🐘 PostgresNext.js (Turbopack)2.152s3.014s0.862s101.73x
🐘 PostgresNitro2.170s (+12.1% 🔺)2.679s (~)0.510s121.75x
🐘 PostgresExpress2.493s (+2.4%)3.013s (~)0.520s102.01x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.461s (~)3.468s (+5.4% 🔺)1.007s91.00x
▲ VercelExpress2.718s (+8.9% 🔺)3.852s (+8.5% 🔺)1.133s81.10x
▲ VercelNext.js (Turbopack)3.021s (-12.3% 🟢)4.174s (-5.5% 🟢)1.153s81.23x

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

Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro2.278s (-13.0% 🟢)3.007s (~)0.728s101.00x
💻 LocalNext.js (Turbopack)2.406s3.007s0.601s101.06x
🌐 RedisNext.js (Turbopack)2.486s3.008s0.522s101.09x
💻 LocalExpress2.570s (-2.6%)3.008s (~)0.438s101.13x
🌐 MongoDBNext.js (Turbopack)4.706s5.177s0.471s62.07x
🐘 PostgresExpress7.952s (-15.1% 🟢)8.527s (-15.0% 🟢)0.576s43.49x
🐘 PostgresNitro10.828s (+12.2% 🔺)11.034s (+10.0% 🔺)0.206s34.75x
🐘 PostgresNext.js (Turbopack)11.555s12.033s0.478s35.07x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.935s (+6.4% 🔺)3.496s (-3.0%)0.561s91.00x
▲ VercelNext.js (Turbopack)2.946s (-19.9% 🟢)3.697s (-19.4% 🟢)0.751s91.00x
▲ VercelExpress4.071s (+44.0% 🔺)5.217s (+29.8% 🔺)1.146s61.39x

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

Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)4.088s4.582s0.494s71.00x
💻 LocalNitro6.301s (-18.7% 🟢)7.014s (-12.5% 🟢)0.713s51.54x
💻 LocalNext.js (Turbopack)6.918s7.515s0.597s41.69x
💻 LocalExpress7.310s (-5.0%)8.018s (~)0.708s41.79x
🌐 MongoDBNext.js (Turbopack)9.735s10.348s0.613s32.38x
🐘 PostgresExpress48.561s (+5.3% 🔺)49.117s (+4.2%)0.556s111.88x
🐘 PostgresNitro49.528s (+1.5%)50.127s (+2.0%)0.599s112.12x
🐘 PostgresNext.js (Turbopack)50.695s51.116s0.421s112.40x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.161s (-12.3% 🟢)4.394s (-10.0% 🟢)1.233s71.00x
▲ VercelNext.js (Turbopack)4.520s (+18.0% 🔺)5.941s (+15.7% 🔺)1.421s61.43x
▲ VercelExpress4.594s (+13.7% 🔺)5.580s (+7.6% 🔺)0.986s61.45x

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

Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)1.257s2.006s0.749s151.00x
💻 LocalNitro1.383s (-4.4%)2.005s (~)0.622s151.10x
💻 LocalExpress1.411s (-2.1%)2.006s (~)0.595s151.12x
💻 LocalNext.js (Turbopack)1.418s2.006s0.588s151.13x
🐘 PostgresNitro1.795s (-18.2% 🟢)2.011s (-22.6% 🟢)0.216s151.43x
🐘 PostgresExpress2.016s (-8.8% 🟢)2.513s (-6.3% 🟢)0.498s121.60x
🌐 MongoDBNext.js (Turbopack)2.156s3.007s0.851s101.71x
🐘 PostgresNext.js (Turbopack)2.205s2.596s0.391s121.75x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)2.376s (+4.4%)3.652s (+12.3% 🔺)1.276s91.00x
▲ VercelNitro2.423s (+2.8%)3.465s (+5.7% 🔺)1.042s91.02x
▲ VercelExpress2.466s (-0.8%)3.460s (-3.6%)0.994s91.04x

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

Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro2.392s (-13.5% 🟢)3.008s (~)0.616s101.00x
🌐 RedisNext.js (Turbopack)2.500s3.008s0.508s101.05x
💻 LocalNext.js (Turbopack)2.547s3.008s0.460s101.07x
💻 LocalExpress2.684s (-3.1%)3.007s (~)0.323s101.12x
🌐 MongoDBNext.js (Turbopack)4.678s5.177s0.499s61.96x
🐘 PostgresNitro11.136s (+1.0%)11.703s (+2.9%)0.567s34.66x
🐘 PostgresExpress11.259s (-9.2% 🟢)11.697s (-10.3% 🟢)0.438s34.71x
🐘 PostgresNext.js (Turbopack)11.602s12.365s0.763s34.85x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.466s (+0.6%)3.089s (-9.5% 🟢)0.623s101.00x
▲ VercelNext.js (Turbopack)2.614s (+0.9%)4.004s (+11.6% 🔺)1.390s81.06x
▲ VercelExpress3.000s (-15.7% 🟢)3.939s (-14.3% 🟢)0.940s81.22x

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

Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)4.078s4.724s0.646s71.00x
💻 LocalNext.js (Turbopack)6.732s7.213s0.480s51.65x
💻 LocalNitro7.004s (-13.0% 🟢)7.515s (-11.8% 🟢)0.511s41.72x
💻 LocalExpress7.962s (-2.5%)8.519s (-5.6% 🟢)0.557s41.95x
🌐 MongoDBNext.js (Turbopack)9.845s10.347s0.502s32.41x
🐘 PostgresNitro51.308s (+5.8% 🔺)52.116s (+6.1% 🔺)0.808s112.58x
🐘 PostgresExpress51.596s (+2.2%)52.124s (+2.0%)0.528s112.65x
🐘 PostgresNext.js (Turbopack)53.052s53.112s0.060s113.01x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express3.070s (-25.8% 🟢)3.981s (-21.3% 🟢)0.911s81.00x
▲ VercelNitro3.728s (+13.0% 🔺)4.929s (+5.5% 🔺)1.201s71.21x
▲ VercelNext.js (Turbopack)3.910s (-17.0% 🟢)5.060s (-16.6% 🟢)1.149s61.27x

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

Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.111s (-37.2% 🟢)1.002s (~)0.009s (-22.5% 🟢)1.014s (~)0.903s101.00x
💻 LocalNext.js (Turbopack)0.119s1.001s0.010s1.016s0.897s101.07x
🌐 RedisNext.js (Turbopack)0.146s1.000s0.001s1.007s0.861s101.31x
💻 LocalExpress0.172s (~)1.002s (~)0.011s (-8.3% 🟢)1.016s (~)0.844s101.55x
🌐 MongoDBNext.js (Turbopack)0.492s0.953s0.002s1.008s0.516s104.43x
🐘 PostgresNext.js (Turbopack)1.435s1.625s0.001s2.013s0.578s1012.92x
🐘 PostgresExpress2.224s (+61.8% 🔺)2.818s (+69.3% 🔺)0.001s (-6.7% 🟢)3.015s (+49.8% 🔺)0.791s1020.02x
🐘 PostgresNitro2.286s (+82.0% 🔺)2.748s (+48.2% 🔺)0.001s (-14.3% 🟢)3.014s (+49.7% 🔺)0.728s1020.58x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)2.006s (-9.5% 🟢)2.652s (-10.0% 🟢)0.437s (+110.4% 🔺)3.667s (-1.7%)1.661s101.00x
▲ VercelExpress2.147s (-11.8% 🟢)2.782s (-6.1% 🟢)0.242s (+15.2% 🔺)3.673s (-2.5%)1.526s101.07x
▲ VercelNitro2.311s (+12.2% 🔺)2.586s (+8.1% 🔺)0.254s (+0.8%)3.467s (+7.7% 🔺)1.157s101.15x

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

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro11/12
🐘 PostgresNext.js (Turbopack)6/12
▲ VercelNitro7/12
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express💻 Local10/12
Next.js (Turbopack)🌐 Redis6/12
Nitro💻 Local10/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>

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
packages/core/src/events-consumer.tsImplements deferred orphaned event detection using setTimeout(0) with cancellation on new subscribes
packages/core/src/events-consumer.test.tsAdds unit tests for onUnconsumedEvent callback covering null events, orphaned events, and subscribe cancellation
packages/core/src/workflow.tsWires EventsConsumer with onUnconsumedEvent callback that rejects workflow via workflowDiscontinuation
packages/core/src/workflow.test.tsAdds integration tests for duplicate wait_completed, duplicate step_completed, and orphaned events blocking workflow execution
packages/core/src/workflow/sleep.test.tsUpdates 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 threadpackages/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>

@VaguelySeriousVaguelySerious left a comment

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.

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
ContributorAuthor

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.

pranaygpand 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 freeto 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

@pranaygp@TooTallNate@VaguelySerious
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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

@pranaygppranaygp commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

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>
CopilotAI review requested due to automatic review settings February 13, 2026 23:57
@vercel

vercelBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-botBot commented Feb 13, 2026

Copy link
Copy Markdown

🦋 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
NameType
@workflow/corePatch
@workflow/errorsPatch
@workflow/buildersPatch
@workflow/cliPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/web-sharedPatch
workflowPatch
@workflow/world-localPatch
@workflow/world-postgresPatch
@workflow/world-vercelPatch
@workflow/astroPatch
@workflow/nestPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
@workflow/vitePatch
@workflow/world-testingPatch
@workflow/nuxtPatch

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

github-actionsBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

Some tests failed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production512038550
✅ 💻 Local Development532068600
✅ 📦 Local Production532068600
✅ 🐘 Local Postgres532068600
✅ 🪟 Windows470350
❌ 🌍 Community Worlds107439159
✅ 📋 Other129021150
Total2391432752709

❌ 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
AppPassedFailedSkipped
✅ astro4604
✅ example4604
✅ express4604
✅ fastify4604
✅ hono4604
✅ nextjs-turbopack4901
✅ nextjs-webpack4901
✅ nitro4604
✅ nuxt4604
✅ sveltekit4604
✅ vite4604
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack4703
❌ 🌍 Community Worlds
AppPassedFailedSkipped
✅ mongodb-dev300
✅ mongodb4703
✅ redis-dev300
✅ redis4703
✅ turso-dev300
❌ turso4433
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable4307
✅ e2e-local-postgres-nest-stable4307
✅ e2e-local-prod-nest-stable4307

📋 View full workflow run

@github-actions

github-actionsBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

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

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.026s (-22.8% 🟢)1.005s (~)0.979s101.00x
💻 LocalExpress0.031s (-3.4%)1.004s (~)0.973s101.20x
💻 LocalNext.js (Turbopack)0.039s1.006s0.967s101.48x
🌐 RedisNext.js (Turbopack)0.048s1.005s0.957s101.84x
🌐 MongoDBNext.js (Turbopack)0.088s1.007s0.919s103.40x
🐘 PostgresExpress0.105s (-8.1% 🟢)1.009s (~)0.904s104.06x
🐘 PostgresNitro0.479s (~)1.009s (~)0.530s1018.42x
🐘 PostgresNext.js (Turbopack)0.493s1.010s0.517s1018.97x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro0.582s (+10.0% 🔺)1.972s (+14.7% 🔺)1.390s101.00x
▲ VercelExpress0.604s (~)2.120s (+1.0%)1.516s101.04x
▲ VercelNext.js (Turbopack)0.637s (-15.7% 🟢)2.191s (-0.7%)1.554s101.10x

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

workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro1.072s (-3.2%)2.005s (~)0.933s101.00x
💻 LocalNext.js (Turbopack)1.086s2.005s0.920s101.01x
🌐 RedisNext.js (Turbopack)1.100s2.006s0.906s101.03x
💻 LocalExpress1.105s (~)2.005s (~)0.900s101.03x
🌐 MongoDBNext.js (Turbopack)1.305s2.008s0.703s101.22x
🐘 PostgresNext.js (Turbopack)2.270s2.813s0.543s102.12x
🐘 PostgresNitro2.354s (~)3.014s (~)0.659s102.20x
🐘 PostgresExpress2.492s (+25.5% 🔺)3.013s (+24.9% 🔺)0.521s102.33x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.232s (-18.2% 🟢)2.848s (-19.7% 🟢)0.616s101.00x
▲ VercelExpress2.283s (-54.2% 🟢)3.327s (-45.2% 🟢)1.044s101.02x
▲ VercelNext.js (Turbopack)2.377s (-54.2% 🟢)3.234s (-49.2% 🟢)0.857s101.06x

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

workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro10.551s (-2.5%)11.023s (~)0.472s31.00x
💻 LocalNext.js (Turbopack)10.651s11.022s0.371s31.01x
🌐 RedisNext.js (Turbopack)10.739s11.022s0.283s31.02x
💻 LocalExpress10.824s (~)11.022s (~)0.198s31.03x
🌐 MongoDBNext.js (Turbopack)12.306s13.024s0.718s31.17x
🐘 PostgresNext.js (Turbopack)15.242s16.046s0.804s21.44x
🐘 PostgresNitro20.210s (~)21.056s (~)0.846s21.92x
🐘 PostgresExpress20.376s (+32.6% 🔺)21.057s (+31.2% 🔺)0.681s21.93x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro16.978s (-1.4%)17.871s (~)0.893s21.00x
▲ VercelExpress17.579s (-2.9%)18.868s (-2.7%)1.289s21.04x
▲ VercelNext.js (Turbopack)17.705s (+1.3%)18.855s (~)1.150s21.04x

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

workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro26.775s (-2.7%)27.052s (-3.6%)0.277s31.00x
🌐 RedisNext.js (Turbopack)26.858s27.050s0.192s31.00x
💻 LocalNext.js (Turbopack)27.007s27.049s0.042s31.01x
💻 LocalExpress27.474s (~)28.051s (~)0.577s31.03x
🌐 MongoDBNext.js (Turbopack)30.506s31.042s0.536s21.14x
🐘 PostgresNext.js (Turbopack)37.629s38.093s0.464s21.41x
🐘 PostgresExpress50.226s (+33.2% 🔺)51.131s (+34.2% 🔺)0.905s21.88x
🐘 PostgresNitro50.492s (+11.0% 🔺)51.126s (+10.9% 🔺)0.634s21.89x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)44.103s (+0.5%)45.512s (+1.5%)1.409s21.00x
▲ VercelExpress45.438s (+5.7% 🔺)46.786s (+4.6%)1.348s21.03x
▲ VercelNitro48.197s (+2.2%)49.197s (+2.3%)0.999s21.09x

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

workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)54.359s55.096s0.737s21.00x
💻 LocalNitro55.645s (-3.1%)56.101s (-3.4%)0.455s21.02x
💻 LocalNext.js (Turbopack)56.337s57.101s0.764s21.04x
💻 LocalExpress57.272s (~)58.103s (~)0.831s21.05x
🌐 MongoDBNext.js (Turbopack)60.993s61.067s0.074s21.12x
🐘 PostgresNext.js (Turbopack)76.103s76.683s0.580s21.40x
🐘 PostgresNitro100.155s (+31.5% 🔺)100.214s (+30.7% 🔺)0.059s11.84x
🐘 PostgresExpress100.463s (+21.3% 🔺)101.232s (+20.9% 🔺)0.769s11.85x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express90.127s (+0.7%)90.819s (~)0.692s11.00x
▲ VercelNext.js (Turbopack)90.426s (~)91.209s (~)0.783s11.00x
▲ VercelNitro90.428s (+2.2%)91.592s (+2.4%)1.164s21.00x

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

Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)1.241s2.006s0.765s151.00x
💻 LocalNitro1.347s (-4.4%)2.005s (~)0.658s151.09x
💻 LocalNext.js (Turbopack)1.390s2.005s0.616s151.12x
💻 LocalExpress1.409s (-1.3%)2.006s (~)0.597s151.14x
🌐 MongoDBNext.js (Turbopack)2.139s3.008s0.869s101.72x
🐘 PostgresNext.js (Turbopack)2.152s3.014s0.862s101.73x
🐘 PostgresNitro2.170s (+12.1% 🔺)2.679s (~)0.510s121.75x
🐘 PostgresExpress2.493s (+2.4%)3.013s (~)0.520s102.01x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.461s (~)3.468s (+5.4% 🔺)1.007s91.00x
▲ VercelExpress2.718s (+8.9% 🔺)3.852s (+8.5% 🔺)1.133s81.10x
▲ VercelNext.js (Turbopack)3.021s (-12.3% 🟢)4.174s (-5.5% 🟢)1.153s81.23x

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

Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro2.278s (-13.0% 🟢)3.007s (~)0.728s101.00x
💻 LocalNext.js (Turbopack)2.406s3.007s0.601s101.06x
🌐 RedisNext.js (Turbopack)2.486s3.008s0.522s101.09x
💻 LocalExpress2.570s (-2.6%)3.008s (~)0.438s101.13x
🌐 MongoDBNext.js (Turbopack)4.706s5.177s0.471s62.07x
🐘 PostgresExpress7.952s (-15.1% 🟢)8.527s (-15.0% 🟢)0.576s43.49x
🐘 PostgresNitro10.828s (+12.2% 🔺)11.034s (+10.0% 🔺)0.206s34.75x
🐘 PostgresNext.js (Turbopack)11.555s12.033s0.478s35.07x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.935s (+6.4% 🔺)3.496s (-3.0%)0.561s91.00x
▲ VercelNext.js (Turbopack)2.946s (-19.9% 🟢)3.697s (-19.4% 🟢)0.751s91.00x
▲ VercelExpress4.071s (+44.0% 🔺)5.217s (+29.8% 🔺)1.146s61.39x

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

Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)4.088s4.582s0.494s71.00x
💻 LocalNitro6.301s (-18.7% 🟢)7.014s (-12.5% 🟢)0.713s51.54x
💻 LocalNext.js (Turbopack)6.918s7.515s0.597s41.69x
💻 LocalExpress7.310s (-5.0%)8.018s (~)0.708s41.79x
🌐 MongoDBNext.js (Turbopack)9.735s10.348s0.613s32.38x
🐘 PostgresExpress48.561s (+5.3% 🔺)49.117s (+4.2%)0.556s111.88x
🐘 PostgresNitro49.528s (+1.5%)50.127s (+2.0%)0.599s112.12x
🐘 PostgresNext.js (Turbopack)50.695s51.116s0.421s112.40x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.161s (-12.3% 🟢)4.394s (-10.0% 🟢)1.233s71.00x
▲ VercelNext.js (Turbopack)4.520s (+18.0% 🔺)5.941s (+15.7% 🔺)1.421s61.43x
▲ VercelExpress4.594s (+13.7% 🔺)5.580s (+7.6% 🔺)0.986s61.45x

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

Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)1.257s2.006s0.749s151.00x
💻 LocalNitro1.383s (-4.4%)2.005s (~)0.622s151.10x
💻 LocalExpress1.411s (-2.1%)2.006s (~)0.595s151.12x
💻 LocalNext.js (Turbopack)1.418s2.006s0.588s151.13x
🐘 PostgresNitro1.795s (-18.2% 🟢)2.011s (-22.6% 🟢)0.216s151.43x
🐘 PostgresExpress2.016s (-8.8% 🟢)2.513s (-6.3% 🟢)0.498s121.60x
🌐 MongoDBNext.js (Turbopack)2.156s3.007s0.851s101.71x
🐘 PostgresNext.js (Turbopack)2.205s2.596s0.391s121.75x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)2.376s (+4.4%)3.652s (+12.3% 🔺)1.276s91.00x
▲ VercelNitro2.423s (+2.8%)3.465s (+5.7% 🔺)1.042s91.02x
▲ VercelExpress2.466s (-0.8%)3.460s (-3.6%)0.994s91.04x

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

Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro2.392s (-13.5% 🟢)3.008s (~)0.616s101.00x
🌐 RedisNext.js (Turbopack)2.500s3.008s0.508s101.05x
💻 LocalNext.js (Turbopack)2.547s3.008s0.460s101.07x
💻 LocalExpress2.684s (-3.1%)3.007s (~)0.323s101.12x
🌐 MongoDBNext.js (Turbopack)4.678s5.177s0.499s61.96x
🐘 PostgresNitro11.136s (+1.0%)11.703s (+2.9%)0.567s34.66x
🐘 PostgresExpress11.259s (-9.2% 🟢)11.697s (-10.3% 🟢)0.438s34.71x
🐘 PostgresNext.js (Turbopack)11.602s12.365s0.763s34.85x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.466s (+0.6%)3.089s (-9.5% 🟢)0.623s101.00x
▲ VercelNext.js (Turbopack)2.614s (+0.9%)4.004s (+11.6% 🔺)1.390s81.06x
▲ VercelExpress3.000s (-15.7% 🟢)3.939s (-14.3% 🟢)0.940s81.22x

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

Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)4.078s4.724s0.646s71.00x
💻 LocalNext.js (Turbopack)6.732s7.213s0.480s51.65x
💻 LocalNitro7.004s (-13.0% 🟢)7.515s (-11.8% 🟢)0.511s41.72x
💻 LocalExpress7.962s (-2.5%)8.519s (-5.6% 🟢)0.557s41.95x
🌐 MongoDBNext.js (Turbopack)9.845s10.347s0.502s32.41x
🐘 PostgresNitro51.308s (+5.8% 🔺)52.116s (+6.1% 🔺)0.808s112.58x
🐘 PostgresExpress51.596s (+2.2%)52.124s (+2.0%)0.528s112.65x
🐘 PostgresNext.js (Turbopack)53.052s53.112s0.060s113.01x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express3.070s (-25.8% 🟢)3.981s (-21.3% 🟢)0.911s81.00x
▲ VercelNitro3.728s (+13.0% 🔺)4.929s (+5.5% 🔺)1.201s71.21x
▲ VercelNext.js (Turbopack)3.910s (-17.0% 🟢)5.060s (-16.6% 🟢)1.149s61.27x

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

Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.111s (-37.2% 🟢)1.002s (~)0.009s (-22.5% 🟢)1.014s (~)0.903s101.00x
💻 LocalNext.js (Turbopack)0.119s1.001s0.010s1.016s0.897s101.07x
🌐 RedisNext.js (Turbopack)0.146s1.000s0.001s1.007s0.861s101.31x
💻 LocalExpress0.172s (~)1.002s (~)0.011s (-8.3% 🟢)1.016s (~)0.844s101.55x
🌐 MongoDBNext.js (Turbopack)0.492s0.953s0.002s1.008s0.516s104.43x
🐘 PostgresNext.js (Turbopack)1.435s1.625s0.001s2.013s0.578s1012.92x
🐘 PostgresExpress2.224s (+61.8% 🔺)2.818s (+69.3% 🔺)0.001s (-6.7% 🟢)3.015s (+49.8% 🔺)0.791s1020.02x
🐘 PostgresNitro2.286s (+82.0% 🔺)2.748s (+48.2% 🔺)0.001s (-14.3% 🟢)3.014s (+49.7% 🔺)0.728s1020.58x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)2.006s (-9.5% 🟢)2.652s (-10.0% 🟢)0.437s (+110.4% 🔺)3.667s (-1.7%)1.661s101.00x
▲ VercelExpress2.147s (-11.8% 🟢)2.782s (-6.1% 🟢)0.242s (+15.2% 🔺)3.673s (-2.5%)1.526s101.07x
▲ VercelNitro2.311s (+12.2% 🔺)2.586s (+8.1% 🔺)0.254s (+0.8%)3.467s (+7.7% 🔺)1.157s101.15x

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

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro11/12
🐘 PostgresNext.js (Turbopack)6/12
▲ VercelNitro7/12
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express💻 Local10/12
Next.js (Turbopack)🌐 Redis6/12
Nitro💻 Local10/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>

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
packages/core/src/events-consumer.tsImplements deferred orphaned event detection using setTimeout(0) with cancellation on new subscribes
packages/core/src/events-consumer.test.tsAdds unit tests for onUnconsumedEvent callback covering null events, orphaned events, and subscribe cancellation
packages/core/src/workflow.tsWires EventsConsumer with onUnconsumedEvent callback that rejects workflow via workflowDiscontinuation
packages/core/src/workflow.test.tsAdds integration tests for duplicate wait_completed, duplicate step_completed, and orphaned events blocking workflow execution
packages/core/src/workflow/sleep.test.tsUpdates 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 threadpackages/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>

@VaguelySeriousVaguelySerious left a comment

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.

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
ContributorAuthor

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.

pranaygpand 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 freeto 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

@pranaygp@TooTallNate@VaguelySerious
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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

@pranaygppranaygp commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

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>
CopilotAI review requested due to automatic review settings February 13, 2026 23:57
@vercel

vercelBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-botBot commented Feb 13, 2026

Copy link
Copy Markdown

🦋 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
NameType
@workflow/corePatch
@workflow/errorsPatch
@workflow/buildersPatch
@workflow/cliPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/web-sharedPatch
workflowPatch
@workflow/world-localPatch
@workflow/world-postgresPatch
@workflow/world-vercelPatch
@workflow/astroPatch
@workflow/nestPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
@workflow/vitePatch
@workflow/world-testingPatch
@workflow/nuxtPatch

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

github-actionsBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

Some tests failed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production512038550
✅ 💻 Local Development532068600
✅ 📦 Local Production532068600
✅ 🐘 Local Postgres532068600
✅ 🪟 Windows470350
❌ 🌍 Community Worlds107439159
✅ 📋 Other129021150
Total2391432752709

❌ 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
AppPassedFailedSkipped
✅ astro4604
✅ example4604
✅ express4604
✅ fastify4604
✅ hono4604
✅ nextjs-turbopack4901
✅ nextjs-webpack4901
✅ nitro4604
✅ nuxt4604
✅ sveltekit4604
✅ vite4604
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack4703
❌ 🌍 Community Worlds
AppPassedFailedSkipped
✅ mongodb-dev300
✅ mongodb4703
✅ redis-dev300
✅ redis4703
✅ turso-dev300
❌ turso4433
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable4307
✅ e2e-local-postgres-nest-stable4307
✅ e2e-local-prod-nest-stable4307

📋 View full workflow run

@github-actions

github-actionsBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

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

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.026s (-22.8% 🟢)1.005s (~)0.979s101.00x
💻 LocalExpress0.031s (-3.4%)1.004s (~)0.973s101.20x
💻 LocalNext.js (Turbopack)0.039s1.006s0.967s101.48x
🌐 RedisNext.js (Turbopack)0.048s1.005s0.957s101.84x
🌐 MongoDBNext.js (Turbopack)0.088s1.007s0.919s103.40x
🐘 PostgresExpress0.105s (-8.1% 🟢)1.009s (~)0.904s104.06x
🐘 PostgresNitro0.479s (~)1.009s (~)0.530s1018.42x
🐘 PostgresNext.js (Turbopack)0.493s1.010s0.517s1018.97x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro0.582s (+10.0% 🔺)1.972s (+14.7% 🔺)1.390s101.00x
▲ VercelExpress0.604s (~)2.120s (+1.0%)1.516s101.04x
▲ VercelNext.js (Turbopack)0.637s (-15.7% 🟢)2.191s (-0.7%)1.554s101.10x

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

workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro1.072s (-3.2%)2.005s (~)0.933s101.00x
💻 LocalNext.js (Turbopack)1.086s2.005s0.920s101.01x
🌐 RedisNext.js (Turbopack)1.100s2.006s0.906s101.03x
💻 LocalExpress1.105s (~)2.005s (~)0.900s101.03x
🌐 MongoDBNext.js (Turbopack)1.305s2.008s0.703s101.22x
🐘 PostgresNext.js (Turbopack)2.270s2.813s0.543s102.12x
🐘 PostgresNitro2.354s (~)3.014s (~)0.659s102.20x
🐘 PostgresExpress2.492s (+25.5% 🔺)3.013s (+24.9% 🔺)0.521s102.33x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.232s (-18.2% 🟢)2.848s (-19.7% 🟢)0.616s101.00x
▲ VercelExpress2.283s (-54.2% 🟢)3.327s (-45.2% 🟢)1.044s101.02x
▲ VercelNext.js (Turbopack)2.377s (-54.2% 🟢)3.234s (-49.2% 🟢)0.857s101.06x

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

workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro10.551s (-2.5%)11.023s (~)0.472s31.00x
💻 LocalNext.js (Turbopack)10.651s11.022s0.371s31.01x
🌐 RedisNext.js (Turbopack)10.739s11.022s0.283s31.02x
💻 LocalExpress10.824s (~)11.022s (~)0.198s31.03x
🌐 MongoDBNext.js (Turbopack)12.306s13.024s0.718s31.17x
🐘 PostgresNext.js (Turbopack)15.242s16.046s0.804s21.44x
🐘 PostgresNitro20.210s (~)21.056s (~)0.846s21.92x
🐘 PostgresExpress20.376s (+32.6% 🔺)21.057s (+31.2% 🔺)0.681s21.93x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro16.978s (-1.4%)17.871s (~)0.893s21.00x
▲ VercelExpress17.579s (-2.9%)18.868s (-2.7%)1.289s21.04x
▲ VercelNext.js (Turbopack)17.705s (+1.3%)18.855s (~)1.150s21.04x

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

workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro26.775s (-2.7%)27.052s (-3.6%)0.277s31.00x
🌐 RedisNext.js (Turbopack)26.858s27.050s0.192s31.00x
💻 LocalNext.js (Turbopack)27.007s27.049s0.042s31.01x
💻 LocalExpress27.474s (~)28.051s (~)0.577s31.03x
🌐 MongoDBNext.js (Turbopack)30.506s31.042s0.536s21.14x
🐘 PostgresNext.js (Turbopack)37.629s38.093s0.464s21.41x
🐘 PostgresExpress50.226s (+33.2% 🔺)51.131s (+34.2% 🔺)0.905s21.88x
🐘 PostgresNitro50.492s (+11.0% 🔺)51.126s (+10.9% 🔺)0.634s21.89x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)44.103s (+0.5%)45.512s (+1.5%)1.409s21.00x
▲ VercelExpress45.438s (+5.7% 🔺)46.786s (+4.6%)1.348s21.03x
▲ VercelNitro48.197s (+2.2%)49.197s (+2.3%)0.999s21.09x

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

workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)54.359s55.096s0.737s21.00x
💻 LocalNitro55.645s (-3.1%)56.101s (-3.4%)0.455s21.02x
💻 LocalNext.js (Turbopack)56.337s57.101s0.764s21.04x
💻 LocalExpress57.272s (~)58.103s (~)0.831s21.05x
🌐 MongoDBNext.js (Turbopack)60.993s61.067s0.074s21.12x
🐘 PostgresNext.js (Turbopack)76.103s76.683s0.580s21.40x
🐘 PostgresNitro100.155s (+31.5% 🔺)100.214s (+30.7% 🔺)0.059s11.84x
🐘 PostgresExpress100.463s (+21.3% 🔺)101.232s (+20.9% 🔺)0.769s11.85x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express90.127s (+0.7%)90.819s (~)0.692s11.00x
▲ VercelNext.js (Turbopack)90.426s (~)91.209s (~)0.783s11.00x
▲ VercelNitro90.428s (+2.2%)91.592s (+2.4%)1.164s21.00x

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

Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)1.241s2.006s0.765s151.00x
💻 LocalNitro1.347s (-4.4%)2.005s (~)0.658s151.09x
💻 LocalNext.js (Turbopack)1.390s2.005s0.616s151.12x
💻 LocalExpress1.409s (-1.3%)2.006s (~)0.597s151.14x
🌐 MongoDBNext.js (Turbopack)2.139s3.008s0.869s101.72x
🐘 PostgresNext.js (Turbopack)2.152s3.014s0.862s101.73x
🐘 PostgresNitro2.170s (+12.1% 🔺)2.679s (~)0.510s121.75x
🐘 PostgresExpress2.493s (+2.4%)3.013s (~)0.520s102.01x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.461s (~)3.468s (+5.4% 🔺)1.007s91.00x
▲ VercelExpress2.718s (+8.9% 🔺)3.852s (+8.5% 🔺)1.133s81.10x
▲ VercelNext.js (Turbopack)3.021s (-12.3% 🟢)4.174s (-5.5% 🟢)1.153s81.23x

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

Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro2.278s (-13.0% 🟢)3.007s (~)0.728s101.00x
💻 LocalNext.js (Turbopack)2.406s3.007s0.601s101.06x
🌐 RedisNext.js (Turbopack)2.486s3.008s0.522s101.09x
💻 LocalExpress2.570s (-2.6%)3.008s (~)0.438s101.13x
🌐 MongoDBNext.js (Turbopack)4.706s5.177s0.471s62.07x
🐘 PostgresExpress7.952s (-15.1% 🟢)8.527s (-15.0% 🟢)0.576s43.49x
🐘 PostgresNitro10.828s (+12.2% 🔺)11.034s (+10.0% 🔺)0.206s34.75x
🐘 PostgresNext.js (Turbopack)11.555s12.033s0.478s35.07x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.935s (+6.4% 🔺)3.496s (-3.0%)0.561s91.00x
▲ VercelNext.js (Turbopack)2.946s (-19.9% 🟢)3.697s (-19.4% 🟢)0.751s91.00x
▲ VercelExpress4.071s (+44.0% 🔺)5.217s (+29.8% 🔺)1.146s61.39x

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

Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)4.088s4.582s0.494s71.00x
💻 LocalNitro6.301s (-18.7% 🟢)7.014s (-12.5% 🟢)0.713s51.54x
💻 LocalNext.js (Turbopack)6.918s7.515s0.597s41.69x
💻 LocalExpress7.310s (-5.0%)8.018s (~)0.708s41.79x
🌐 MongoDBNext.js (Turbopack)9.735s10.348s0.613s32.38x
🐘 PostgresExpress48.561s (+5.3% 🔺)49.117s (+4.2%)0.556s111.88x
🐘 PostgresNitro49.528s (+1.5%)50.127s (+2.0%)0.599s112.12x
🐘 PostgresNext.js (Turbopack)50.695s51.116s0.421s112.40x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.161s (-12.3% 🟢)4.394s (-10.0% 🟢)1.233s71.00x
▲ VercelNext.js (Turbopack)4.520s (+18.0% 🔺)5.941s (+15.7% 🔺)1.421s61.43x
▲ VercelExpress4.594s (+13.7% 🔺)5.580s (+7.6% 🔺)0.986s61.45x

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

Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)1.257s2.006s0.749s151.00x
💻 LocalNitro1.383s (-4.4%)2.005s (~)0.622s151.10x
💻 LocalExpress1.411s (-2.1%)2.006s (~)0.595s151.12x
💻 LocalNext.js (Turbopack)1.418s2.006s0.588s151.13x
🐘 PostgresNitro1.795s (-18.2% 🟢)2.011s (-22.6% 🟢)0.216s151.43x
🐘 PostgresExpress2.016s (-8.8% 🟢)2.513s (-6.3% 🟢)0.498s121.60x
🌐 MongoDBNext.js (Turbopack)2.156s3.007s0.851s101.71x
🐘 PostgresNext.js (Turbopack)2.205s2.596s0.391s121.75x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)2.376s (+4.4%)3.652s (+12.3% 🔺)1.276s91.00x
▲ VercelNitro2.423s (+2.8%)3.465s (+5.7% 🔺)1.042s91.02x
▲ VercelExpress2.466s (-0.8%)3.460s (-3.6%)0.994s91.04x

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

Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro2.392s (-13.5% 🟢)3.008s (~)0.616s101.00x
🌐 RedisNext.js (Turbopack)2.500s3.008s0.508s101.05x
💻 LocalNext.js (Turbopack)2.547s3.008s0.460s101.07x
💻 LocalExpress2.684s (-3.1%)3.007s (~)0.323s101.12x
🌐 MongoDBNext.js (Turbopack)4.678s5.177s0.499s61.96x
🐘 PostgresNitro11.136s (+1.0%)11.703s (+2.9%)0.567s34.66x
🐘 PostgresExpress11.259s (-9.2% 🟢)11.697s (-10.3% 🟢)0.438s34.71x
🐘 PostgresNext.js (Turbopack)11.602s12.365s0.763s34.85x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.466s (+0.6%)3.089s (-9.5% 🟢)0.623s101.00x
▲ VercelNext.js (Turbopack)2.614s (+0.9%)4.004s (+11.6% 🔺)1.390s81.06x
▲ VercelExpress3.000s (-15.7% 🟢)3.939s (-14.3% 🟢)0.940s81.22x

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

Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)4.078s4.724s0.646s71.00x
💻 LocalNext.js (Turbopack)6.732s7.213s0.480s51.65x
💻 LocalNitro7.004s (-13.0% 🟢)7.515s (-11.8% 🟢)0.511s41.72x
💻 LocalExpress7.962s (-2.5%)8.519s (-5.6% 🟢)0.557s41.95x
🌐 MongoDBNext.js (Turbopack)9.845s10.347s0.502s32.41x
🐘 PostgresNitro51.308s (+5.8% 🔺)52.116s (+6.1% 🔺)0.808s112.58x
🐘 PostgresExpress51.596s (+2.2%)52.124s (+2.0%)0.528s112.65x
🐘 PostgresNext.js (Turbopack)53.052s53.112s0.060s113.01x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express3.070s (-25.8% 🟢)3.981s (-21.3% 🟢)0.911s81.00x
▲ VercelNitro3.728s (+13.0% 🔺)4.929s (+5.5% 🔺)1.201s71.21x
▲ VercelNext.js (Turbopack)3.910s (-17.0% 🟢)5.060s (-16.6% 🟢)1.149s61.27x

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

Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.111s (-37.2% 🟢)1.002s (~)0.009s (-22.5% 🟢)1.014s (~)0.903s101.00x
💻 LocalNext.js (Turbopack)0.119s1.001s0.010s1.016s0.897s101.07x
🌐 RedisNext.js (Turbopack)0.146s1.000s0.001s1.007s0.861s101.31x
💻 LocalExpress0.172s (~)1.002s (~)0.011s (-8.3% 🟢)1.016s (~)0.844s101.55x
🌐 MongoDBNext.js (Turbopack)0.492s0.953s0.002s1.008s0.516s104.43x
🐘 PostgresNext.js (Turbopack)1.435s1.625s0.001s2.013s0.578s1012.92x
🐘 PostgresExpress2.224s (+61.8% 🔺)2.818s (+69.3% 🔺)0.001s (-6.7% 🟢)3.015s (+49.8% 🔺)0.791s1020.02x
🐘 PostgresNitro2.286s (+82.0% 🔺)2.748s (+48.2% 🔺)0.001s (-14.3% 🟢)3.014s (+49.7% 🔺)0.728s1020.58x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)2.006s (-9.5% 🟢)2.652s (-10.0% 🟢)0.437s (+110.4% 🔺)3.667s (-1.7%)1.661s101.00x
▲ VercelExpress2.147s (-11.8% 🟢)2.782s (-6.1% 🟢)0.242s (+15.2% 🔺)3.673s (-2.5%)1.526s101.07x
▲ VercelNitro2.311s (+12.2% 🔺)2.586s (+8.1% 🔺)0.254s (+0.8%)3.467s (+7.7% 🔺)1.157s101.15x

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

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro11/12
🐘 PostgresNext.js (Turbopack)6/12
▲ VercelNitro7/12
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express💻 Local10/12
Next.js (Turbopack)🌐 Redis6/12
Nitro💻 Local10/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>

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
packages/core/src/events-consumer.tsImplements deferred orphaned event detection using setTimeout(0) with cancellation on new subscribes
packages/core/src/events-consumer.test.tsAdds unit tests for onUnconsumedEvent callback covering null events, orphaned events, and subscribe cancellation
packages/core/src/workflow.tsWires EventsConsumer with onUnconsumedEvent callback that rejects workflow via workflowDiscontinuation
packages/core/src/workflow.test.tsAdds integration tests for duplicate wait_completed, duplicate step_completed, and orphaned events blocking workflow execution
packages/core/src/workflow/sleep.test.tsUpdates 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 threadpackages/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>

@VaguelySeriousVaguelySerious left a comment

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.

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
ContributorAuthor

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.

pranaygpand 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 freeto 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

@pranaygp@TooTallNate@VaguelySerious
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
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

@pranaygppranaygp commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

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>
CopilotAI review requested due to automatic review settings February 13, 2026 23:57
@vercel

vercelBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-botBot commented Feb 13, 2026

Copy link
Copy Markdown

🦋 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
NameType
@workflow/corePatch
@workflow/errorsPatch
@workflow/buildersPatch
@workflow/cliPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/web-sharedPatch
workflowPatch
@workflow/world-localPatch
@workflow/world-postgresPatch
@workflow/world-vercelPatch
@workflow/astroPatch
@workflow/nestPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
@workflow/vitePatch
@workflow/world-testingPatch
@workflow/nuxtPatch

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

github-actionsBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

Some tests failed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production512038550
✅ 💻 Local Development532068600
✅ 📦 Local Production532068600
✅ 🐘 Local Postgres532068600
✅ 🪟 Windows470350
❌ 🌍 Community Worlds107439159
✅ 📋 Other129021150
Total2391432752709

❌ 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
AppPassedFailedSkipped
✅ astro4604
✅ example4604
✅ express4604
✅ fastify4604
✅ hono4604
✅ nextjs-turbopack4901
✅ nextjs-webpack4901
✅ nitro4604
✅ nuxt4604
✅ sveltekit4604
✅ vite4604
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack4703
❌ 🌍 Community Worlds
AppPassedFailedSkipped
✅ mongodb-dev300
✅ mongodb4703
✅ redis-dev300
✅ redis4703
✅ turso-dev300
❌ turso4433
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable4307
✅ e2e-local-postgres-nest-stable4307
✅ e2e-local-prod-nest-stable4307

📋 View full workflow run

@github-actions

github-actionsBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

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

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.026s (-22.8% 🟢)1.005s (~)0.979s101.00x
💻 LocalExpress0.031s (-3.4%)1.004s (~)0.973s101.20x
💻 LocalNext.js (Turbopack)0.039s1.006s0.967s101.48x
🌐 RedisNext.js (Turbopack)0.048s1.005s0.957s101.84x
🌐 MongoDBNext.js (Turbopack)0.088s1.007s0.919s103.40x
🐘 PostgresExpress0.105s (-8.1% 🟢)1.009s (~)0.904s104.06x
🐘 PostgresNitro0.479s (~)1.009s (~)0.530s1018.42x
🐘 PostgresNext.js (Turbopack)0.493s1.010s0.517s1018.97x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro0.582s (+10.0% 🔺)1.972s (+14.7% 🔺)1.390s101.00x
▲ VercelExpress0.604s (~)2.120s (+1.0%)1.516s101.04x
▲ VercelNext.js (Turbopack)0.637s (-15.7% 🟢)2.191s (-0.7%)1.554s101.10x

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

workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro1.072s (-3.2%)2.005s (~)0.933s101.00x
💻 LocalNext.js (Turbopack)1.086s2.005s0.920s101.01x
🌐 RedisNext.js (Turbopack)1.100s2.006s0.906s101.03x
💻 LocalExpress1.105s (~)2.005s (~)0.900s101.03x
🌐 MongoDBNext.js (Turbopack)1.305s2.008s0.703s101.22x
🐘 PostgresNext.js (Turbopack)2.270s2.813s0.543s102.12x
🐘 PostgresNitro2.354s (~)3.014s (~)0.659s102.20x
🐘 PostgresExpress2.492s (+25.5% 🔺)3.013s (+24.9% 🔺)0.521s102.33x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.232s (-18.2% 🟢)2.848s (-19.7% 🟢)0.616s101.00x
▲ VercelExpress2.283s (-54.2% 🟢)3.327s (-45.2% 🟢)1.044s101.02x
▲ VercelNext.js (Turbopack)2.377s (-54.2% 🟢)3.234s (-49.2% 🟢)0.857s101.06x

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

workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro10.551s (-2.5%)11.023s (~)0.472s31.00x
💻 LocalNext.js (Turbopack)10.651s11.022s0.371s31.01x
🌐 RedisNext.js (Turbopack)10.739s11.022s0.283s31.02x
💻 LocalExpress10.824s (~)11.022s (~)0.198s31.03x
🌐 MongoDBNext.js (Turbopack)12.306s13.024s0.718s31.17x
🐘 PostgresNext.js (Turbopack)15.242s16.046s0.804s21.44x
🐘 PostgresNitro20.210s (~)21.056s (~)0.846s21.92x
🐘 PostgresExpress20.376s (+32.6% 🔺)21.057s (+31.2% 🔺)0.681s21.93x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro16.978s (-1.4%)17.871s (~)0.893s21.00x
▲ VercelExpress17.579s (-2.9%)18.868s (-2.7%)1.289s21.04x
▲ VercelNext.js (Turbopack)17.705s (+1.3%)18.855s (~)1.150s21.04x

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

workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro26.775s (-2.7%)27.052s (-3.6%)0.277s31.00x
🌐 RedisNext.js (Turbopack)26.858s27.050s0.192s31.00x
💻 LocalNext.js (Turbopack)27.007s27.049s0.042s31.01x
💻 LocalExpress27.474s (~)28.051s (~)0.577s31.03x
🌐 MongoDBNext.js (Turbopack)30.506s31.042s0.536s21.14x
🐘 PostgresNext.js (Turbopack)37.629s38.093s0.464s21.41x
🐘 PostgresExpress50.226s (+33.2% 🔺)51.131s (+34.2% 🔺)0.905s21.88x
🐘 PostgresNitro50.492s (+11.0% 🔺)51.126s (+10.9% 🔺)0.634s21.89x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)44.103s (+0.5%)45.512s (+1.5%)1.409s21.00x
▲ VercelExpress45.438s (+5.7% 🔺)46.786s (+4.6%)1.348s21.03x
▲ VercelNitro48.197s (+2.2%)49.197s (+2.3%)0.999s21.09x

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

workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)54.359s55.096s0.737s21.00x
💻 LocalNitro55.645s (-3.1%)56.101s (-3.4%)0.455s21.02x
💻 LocalNext.js (Turbopack)56.337s57.101s0.764s21.04x
💻 LocalExpress57.272s (~)58.103s (~)0.831s21.05x
🌐 MongoDBNext.js (Turbopack)60.993s61.067s0.074s21.12x
🐘 PostgresNext.js (Turbopack)76.103s76.683s0.580s21.40x
🐘 PostgresNitro100.155s (+31.5% 🔺)100.214s (+30.7% 🔺)0.059s11.84x
🐘 PostgresExpress100.463s (+21.3% 🔺)101.232s (+20.9% 🔺)0.769s11.85x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express90.127s (+0.7%)90.819s (~)0.692s11.00x
▲ VercelNext.js (Turbopack)90.426s (~)91.209s (~)0.783s11.00x
▲ VercelNitro90.428s (+2.2%)91.592s (+2.4%)1.164s21.00x

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

Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)1.241s2.006s0.765s151.00x
💻 LocalNitro1.347s (-4.4%)2.005s (~)0.658s151.09x
💻 LocalNext.js (Turbopack)1.390s2.005s0.616s151.12x
💻 LocalExpress1.409s (-1.3%)2.006s (~)0.597s151.14x
🌐 MongoDBNext.js (Turbopack)2.139s3.008s0.869s101.72x
🐘 PostgresNext.js (Turbopack)2.152s3.014s0.862s101.73x
🐘 PostgresNitro2.170s (+12.1% 🔺)2.679s (~)0.510s121.75x
🐘 PostgresExpress2.493s (+2.4%)3.013s (~)0.520s102.01x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.461s (~)3.468s (+5.4% 🔺)1.007s91.00x
▲ VercelExpress2.718s (+8.9% 🔺)3.852s (+8.5% 🔺)1.133s81.10x
▲ VercelNext.js (Turbopack)3.021s (-12.3% 🟢)4.174s (-5.5% 🟢)1.153s81.23x

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

Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro2.278s (-13.0% 🟢)3.007s (~)0.728s101.00x
💻 LocalNext.js (Turbopack)2.406s3.007s0.601s101.06x
🌐 RedisNext.js (Turbopack)2.486s3.008s0.522s101.09x
💻 LocalExpress2.570s (-2.6%)3.008s (~)0.438s101.13x
🌐 MongoDBNext.js (Turbopack)4.706s5.177s0.471s62.07x
🐘 PostgresExpress7.952s (-15.1% 🟢)8.527s (-15.0% 🟢)0.576s43.49x
🐘 PostgresNitro10.828s (+12.2% 🔺)11.034s (+10.0% 🔺)0.206s34.75x
🐘 PostgresNext.js (Turbopack)11.555s12.033s0.478s35.07x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.935s (+6.4% 🔺)3.496s (-3.0%)0.561s91.00x
▲ VercelNext.js (Turbopack)2.946s (-19.9% 🟢)3.697s (-19.4% 🟢)0.751s91.00x
▲ VercelExpress4.071s (+44.0% 🔺)5.217s (+29.8% 🔺)1.146s61.39x

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

Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)4.088s4.582s0.494s71.00x
💻 LocalNitro6.301s (-18.7% 🟢)7.014s (-12.5% 🟢)0.713s51.54x
💻 LocalNext.js (Turbopack)6.918s7.515s0.597s41.69x
💻 LocalExpress7.310s (-5.0%)8.018s (~)0.708s41.79x
🌐 MongoDBNext.js (Turbopack)9.735s10.348s0.613s32.38x
🐘 PostgresExpress48.561s (+5.3% 🔺)49.117s (+4.2%)0.556s111.88x
🐘 PostgresNitro49.528s (+1.5%)50.127s (+2.0%)0.599s112.12x
🐘 PostgresNext.js (Turbopack)50.695s51.116s0.421s112.40x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.161s (-12.3% 🟢)4.394s (-10.0% 🟢)1.233s71.00x
▲ VercelNext.js (Turbopack)4.520s (+18.0% 🔺)5.941s (+15.7% 🔺)1.421s61.43x
▲ VercelExpress4.594s (+13.7% 🔺)5.580s (+7.6% 🔺)0.986s61.45x

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

Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)1.257s2.006s0.749s151.00x
💻 LocalNitro1.383s (-4.4%)2.005s (~)0.622s151.10x
💻 LocalExpress1.411s (-2.1%)2.006s (~)0.595s151.12x
💻 LocalNext.js (Turbopack)1.418s2.006s0.588s151.13x
🐘 PostgresNitro1.795s (-18.2% 🟢)2.011s (-22.6% 🟢)0.216s151.43x
🐘 PostgresExpress2.016s (-8.8% 🟢)2.513s (-6.3% 🟢)0.498s121.60x
🌐 MongoDBNext.js (Turbopack)2.156s3.007s0.851s101.71x
🐘 PostgresNext.js (Turbopack)2.205s2.596s0.391s121.75x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)2.376s (+4.4%)3.652s (+12.3% 🔺)1.276s91.00x
▲ VercelNitro2.423s (+2.8%)3.465s (+5.7% 🔺)1.042s91.02x
▲ VercelExpress2.466s (-0.8%)3.460s (-3.6%)0.994s91.04x

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

Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro2.392s (-13.5% 🟢)3.008s (~)0.616s101.00x
🌐 RedisNext.js (Turbopack)2.500s3.008s0.508s101.05x
💻 LocalNext.js (Turbopack)2.547s3.008s0.460s101.07x
💻 LocalExpress2.684s (-3.1%)3.007s (~)0.323s101.12x
🌐 MongoDBNext.js (Turbopack)4.678s5.177s0.499s61.96x
🐘 PostgresNitro11.136s (+1.0%)11.703s (+2.9%)0.567s34.66x
🐘 PostgresExpress11.259s (-9.2% 🟢)11.697s (-10.3% 🟢)0.438s34.71x
🐘 PostgresNext.js (Turbopack)11.602s12.365s0.763s34.85x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.466s (+0.6%)3.089s (-9.5% 🟢)0.623s101.00x
▲ VercelNext.js (Turbopack)2.614s (+0.9%)4.004s (+11.6% 🔺)1.390s81.06x
▲ VercelExpress3.000s (-15.7% 🟢)3.939s (-14.3% 🟢)0.940s81.22x

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

Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)4.078s4.724s0.646s71.00x
💻 LocalNext.js (Turbopack)6.732s7.213s0.480s51.65x
💻 LocalNitro7.004s (-13.0% 🟢)7.515s (-11.8% 🟢)0.511s41.72x
💻 LocalExpress7.962s (-2.5%)8.519s (-5.6% 🟢)0.557s41.95x
🌐 MongoDBNext.js (Turbopack)9.845s10.347s0.502s32.41x
🐘 PostgresNitro51.308s (+5.8% 🔺)52.116s (+6.1% 🔺)0.808s112.58x
🐘 PostgresExpress51.596s (+2.2%)52.124s (+2.0%)0.528s112.65x
🐘 PostgresNext.js (Turbopack)53.052s53.112s0.060s113.01x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express3.070s (-25.8% 🟢)3.981s (-21.3% 🟢)0.911s81.00x
▲ VercelNitro3.728s (+13.0% 🔺)4.929s (+5.5% 🔺)1.201s71.21x
▲ VercelNext.js (Turbopack)3.910s (-17.0% 🟢)5.060s (-16.6% 🟢)1.149s61.27x

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

Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.111s (-37.2% 🟢)1.002s (~)0.009s (-22.5% 🟢)1.014s (~)0.903s101.00x
💻 LocalNext.js (Turbopack)0.119s1.001s0.010s1.016s0.897s101.07x
🌐 RedisNext.js (Turbopack)0.146s1.000s0.001s1.007s0.861s101.31x
💻 LocalExpress0.172s (~)1.002s (~)0.011s (-8.3% 🟢)1.016s (~)0.844s101.55x
🌐 MongoDBNext.js (Turbopack)0.492s0.953s0.002s1.008s0.516s104.43x
🐘 PostgresNext.js (Turbopack)1.435s1.625s0.001s2.013s0.578s1012.92x
🐘 PostgresExpress2.224s (+61.8% 🔺)2.818s (+69.3% 🔺)0.001s (-6.7% 🟢)3.015s (+49.8% 🔺)0.791s1020.02x
🐘 PostgresNitro2.286s (+82.0% 🔺)2.748s (+48.2% 🔺)0.001s (-14.3% 🟢)3.014s (+49.7% 🔺)0.728s1020.58x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)2.006s (-9.5% 🟢)2.652s (-10.0% 🟢)0.437s (+110.4% 🔺)3.667s (-1.7%)1.661s101.00x
▲ VercelExpress2.147s (-11.8% 🟢)2.782s (-6.1% 🟢)0.242s (+15.2% 🔺)3.673s (-2.5%)1.526s101.07x
▲ VercelNitro2.311s (+12.2% 🔺)2.586s (+8.1% 🔺)0.254s (+0.8%)3.467s (+7.7% 🔺)1.157s101.15x

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

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro11/12
🐘 PostgresNext.js (Turbopack)6/12
▲ VercelNitro7/12
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express💻 Local10/12
Next.js (Turbopack)🌐 Redis6/12
Nitro💻 Local10/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>

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
packages/core/src/events-consumer.tsImplements deferred orphaned event detection using setTimeout(0) with cancellation on new subscribes
packages/core/src/events-consumer.test.tsAdds unit tests for onUnconsumedEvent callback covering null events, orphaned events, and subscribe cancellation
packages/core/src/workflow.tsWires EventsConsumer with onUnconsumedEvent callback that rejects workflow via workflowDiscontinuation
packages/core/src/workflow.test.tsAdds integration tests for duplicate wait_completed, duplicate step_completed, and orphaned events blocking workflow execution
packages/core/src/workflow/sleep.test.tsUpdates 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 threadpackages/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>

@VaguelySeriousVaguelySerious left a comment

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.

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
ContributorAuthor

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.

pranaygpand 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 freeto 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

@pranaygp@TooTallNate@VaguelySerious
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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

@pranaygppranaygp commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

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>
CopilotAI review requested due to automatic review settings February 13, 2026 23:57
@vercel

vercelBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-botBot commented Feb 13, 2026

Copy link
Copy Markdown

🦋 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
NameType
@workflow/corePatch
@workflow/errorsPatch
@workflow/buildersPatch
@workflow/cliPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/web-sharedPatch
workflowPatch
@workflow/world-localPatch
@workflow/world-postgresPatch
@workflow/world-vercelPatch
@workflow/astroPatch
@workflow/nestPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
@workflow/vitePatch
@workflow/world-testingPatch
@workflow/nuxtPatch

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

github-actionsBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

Some tests failed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production512038550
✅ 💻 Local Development532068600
✅ 📦 Local Production532068600
✅ 🐘 Local Postgres532068600
✅ 🪟 Windows470350
❌ 🌍 Community Worlds107439159
✅ 📋 Other129021150
Total2391432752709

❌ 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
AppPassedFailedSkipped
✅ astro4604
✅ example4604
✅ express4604
✅ fastify4604
✅ hono4604
✅ nextjs-turbopack4901
✅ nextjs-webpack4901
✅ nitro4604
✅ nuxt4604
✅ sveltekit4604
✅ vite4604
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack4703
❌ 🌍 Community Worlds
AppPassedFailedSkipped
✅ mongodb-dev300
✅ mongodb4703
✅ redis-dev300
✅ redis4703
✅ turso-dev300
❌ turso4433
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable4307
✅ e2e-local-postgres-nest-stable4307
✅ e2e-local-prod-nest-stable4307

📋 View full workflow run

@github-actions

github-actionsBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

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

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.026s (-22.8% 🟢)1.005s (~)0.979s101.00x
💻 LocalExpress0.031s (-3.4%)1.004s (~)0.973s101.20x
💻 LocalNext.js (Turbopack)0.039s1.006s0.967s101.48x
🌐 RedisNext.js (Turbopack)0.048s1.005s0.957s101.84x
🌐 MongoDBNext.js (Turbopack)0.088s1.007s0.919s103.40x
🐘 PostgresExpress0.105s (-8.1% 🟢)1.009s (~)0.904s104.06x
🐘 PostgresNitro0.479s (~)1.009s (~)0.530s1018.42x
🐘 PostgresNext.js (Turbopack)0.493s1.010s0.517s1018.97x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro0.582s (+10.0% 🔺)1.972s (+14.7% 🔺)1.390s101.00x
▲ VercelExpress0.604s (~)2.120s (+1.0%)1.516s101.04x
▲ VercelNext.js (Turbopack)0.637s (-15.7% 🟢)2.191s (-0.7%)1.554s101.10x

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

workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro1.072s (-3.2%)2.005s (~)0.933s101.00x
💻 LocalNext.js (Turbopack)1.086s2.005s0.920s101.01x
🌐 RedisNext.js (Turbopack)1.100s2.006s0.906s101.03x
💻 LocalExpress1.105s (~)2.005s (~)0.900s101.03x
🌐 MongoDBNext.js (Turbopack)1.305s2.008s0.703s101.22x
🐘 PostgresNext.js (Turbopack)2.270s2.813s0.543s102.12x
🐘 PostgresNitro2.354s (~)3.014s (~)0.659s102.20x
🐘 PostgresExpress2.492s (+25.5% 🔺)3.013s (+24.9% 🔺)0.521s102.33x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.232s (-18.2% 🟢)2.848s (-19.7% 🟢)0.616s101.00x
▲ VercelExpress2.283s (-54.2% 🟢)3.327s (-45.2% 🟢)1.044s101.02x
▲ VercelNext.js (Turbopack)2.377s (-54.2% 🟢)3.234s (-49.2% 🟢)0.857s101.06x

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

workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro10.551s (-2.5%)11.023s (~)0.472s31.00x
💻 LocalNext.js (Turbopack)10.651s11.022s0.371s31.01x
🌐 RedisNext.js (Turbopack)10.739s11.022s0.283s31.02x
💻 LocalExpress10.824s (~)11.022s (~)0.198s31.03x
🌐 MongoDBNext.js (Turbopack)12.306s13.024s0.718s31.17x
🐘 PostgresNext.js (Turbopack)15.242s16.046s0.804s21.44x
🐘 PostgresNitro20.210s (~)21.056s (~)0.846s21.92x
🐘 PostgresExpress20.376s (+32.6% 🔺)21.057s (+31.2% 🔺)0.681s21.93x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro16.978s (-1.4%)17.871s (~)0.893s21.00x
▲ VercelExpress17.579s (-2.9%)18.868s (-2.7%)1.289s21.04x
▲ VercelNext.js (Turbopack)17.705s (+1.3%)18.855s (~)1.150s21.04x

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

workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro26.775s (-2.7%)27.052s (-3.6%)0.277s31.00x
🌐 RedisNext.js (Turbopack)26.858s27.050s0.192s31.00x
💻 LocalNext.js (Turbopack)27.007s27.049s0.042s31.01x
💻 LocalExpress27.474s (~)28.051s (~)0.577s31.03x
🌐 MongoDBNext.js (Turbopack)30.506s31.042s0.536s21.14x
🐘 PostgresNext.js (Turbopack)37.629s38.093s0.464s21.41x
🐘 PostgresExpress50.226s (+33.2% 🔺)51.131s (+34.2% 🔺)0.905s21.88x
🐘 PostgresNitro50.492s (+11.0% 🔺)51.126s (+10.9% 🔺)0.634s21.89x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)44.103s (+0.5%)45.512s (+1.5%)1.409s21.00x
▲ VercelExpress45.438s (+5.7% 🔺)46.786s (+4.6%)1.348s21.03x
▲ VercelNitro48.197s (+2.2%)49.197s (+2.3%)0.999s21.09x

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

workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)54.359s55.096s0.737s21.00x
💻 LocalNitro55.645s (-3.1%)56.101s (-3.4%)0.455s21.02x
💻 LocalNext.js (Turbopack)56.337s57.101s0.764s21.04x
💻 LocalExpress57.272s (~)58.103s (~)0.831s21.05x
🌐 MongoDBNext.js (Turbopack)60.993s61.067s0.074s21.12x
🐘 PostgresNext.js (Turbopack)76.103s76.683s0.580s21.40x
🐘 PostgresNitro100.155s (+31.5% 🔺)100.214s (+30.7% 🔺)0.059s11.84x
🐘 PostgresExpress100.463s (+21.3% 🔺)101.232s (+20.9% 🔺)0.769s11.85x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express90.127s (+0.7%)90.819s (~)0.692s11.00x
▲ VercelNext.js (Turbopack)90.426s (~)91.209s (~)0.783s11.00x
▲ VercelNitro90.428s (+2.2%)91.592s (+2.4%)1.164s21.00x

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

Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)1.241s2.006s0.765s151.00x
💻 LocalNitro1.347s (-4.4%)2.005s (~)0.658s151.09x
💻 LocalNext.js (Turbopack)1.390s2.005s0.616s151.12x
💻 LocalExpress1.409s (-1.3%)2.006s (~)0.597s151.14x
🌐 MongoDBNext.js (Turbopack)2.139s3.008s0.869s101.72x
🐘 PostgresNext.js (Turbopack)2.152s3.014s0.862s101.73x
🐘 PostgresNitro2.170s (+12.1% 🔺)2.679s (~)0.510s121.75x
🐘 PostgresExpress2.493s (+2.4%)3.013s (~)0.520s102.01x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.461s (~)3.468s (+5.4% 🔺)1.007s91.00x
▲ VercelExpress2.718s (+8.9% 🔺)3.852s (+8.5% 🔺)1.133s81.10x
▲ VercelNext.js (Turbopack)3.021s (-12.3% 🟢)4.174s (-5.5% 🟢)1.153s81.23x

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

Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro2.278s (-13.0% 🟢)3.007s (~)0.728s101.00x
💻 LocalNext.js (Turbopack)2.406s3.007s0.601s101.06x
🌐 RedisNext.js (Turbopack)2.486s3.008s0.522s101.09x
💻 LocalExpress2.570s (-2.6%)3.008s (~)0.438s101.13x
🌐 MongoDBNext.js (Turbopack)4.706s5.177s0.471s62.07x
🐘 PostgresExpress7.952s (-15.1% 🟢)8.527s (-15.0% 🟢)0.576s43.49x
🐘 PostgresNitro10.828s (+12.2% 🔺)11.034s (+10.0% 🔺)0.206s34.75x
🐘 PostgresNext.js (Turbopack)11.555s12.033s0.478s35.07x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.935s (+6.4% 🔺)3.496s (-3.0%)0.561s91.00x
▲ VercelNext.js (Turbopack)2.946s (-19.9% 🟢)3.697s (-19.4% 🟢)0.751s91.00x
▲ VercelExpress4.071s (+44.0% 🔺)5.217s (+29.8% 🔺)1.146s61.39x

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

Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)4.088s4.582s0.494s71.00x
💻 LocalNitro6.301s (-18.7% 🟢)7.014s (-12.5% 🟢)0.713s51.54x
💻 LocalNext.js (Turbopack)6.918s7.515s0.597s41.69x
💻 LocalExpress7.310s (-5.0%)8.018s (~)0.708s41.79x
🌐 MongoDBNext.js (Turbopack)9.735s10.348s0.613s32.38x
🐘 PostgresExpress48.561s (+5.3% 🔺)49.117s (+4.2%)0.556s111.88x
🐘 PostgresNitro49.528s (+1.5%)50.127s (+2.0%)0.599s112.12x
🐘 PostgresNext.js (Turbopack)50.695s51.116s0.421s112.40x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.161s (-12.3% 🟢)4.394s (-10.0% 🟢)1.233s71.00x
▲ VercelNext.js (Turbopack)4.520s (+18.0% 🔺)5.941s (+15.7% 🔺)1.421s61.43x
▲ VercelExpress4.594s (+13.7% 🔺)5.580s (+7.6% 🔺)0.986s61.45x

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

Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)1.257s2.006s0.749s151.00x
💻 LocalNitro1.383s (-4.4%)2.005s (~)0.622s151.10x
💻 LocalExpress1.411s (-2.1%)2.006s (~)0.595s151.12x
💻 LocalNext.js (Turbopack)1.418s2.006s0.588s151.13x
🐘 PostgresNitro1.795s (-18.2% 🟢)2.011s (-22.6% 🟢)0.216s151.43x
🐘 PostgresExpress2.016s (-8.8% 🟢)2.513s (-6.3% 🟢)0.498s121.60x
🌐 MongoDBNext.js (Turbopack)2.156s3.007s0.851s101.71x
🐘 PostgresNext.js (Turbopack)2.205s2.596s0.391s121.75x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)2.376s (+4.4%)3.652s (+12.3% 🔺)1.276s91.00x
▲ VercelNitro2.423s (+2.8%)3.465s (+5.7% 🔺)1.042s91.02x
▲ VercelExpress2.466s (-0.8%)3.460s (-3.6%)0.994s91.04x

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

Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro2.392s (-13.5% 🟢)3.008s (~)0.616s101.00x
🌐 RedisNext.js (Turbopack)2.500s3.008s0.508s101.05x
💻 LocalNext.js (Turbopack)2.547s3.008s0.460s101.07x
💻 LocalExpress2.684s (-3.1%)3.007s (~)0.323s101.12x
🌐 MongoDBNext.js (Turbopack)4.678s5.177s0.499s61.96x
🐘 PostgresNitro11.136s (+1.0%)11.703s (+2.9%)0.567s34.66x
🐘 PostgresExpress11.259s (-9.2% 🟢)11.697s (-10.3% 🟢)0.438s34.71x
🐘 PostgresNext.js (Turbopack)11.602s12.365s0.763s34.85x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.466s (+0.6%)3.089s (-9.5% 🟢)0.623s101.00x
▲ VercelNext.js (Turbopack)2.614s (+0.9%)4.004s (+11.6% 🔺)1.390s81.06x
▲ VercelExpress3.000s (-15.7% 🟢)3.939s (-14.3% 🟢)0.940s81.22x

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

Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)4.078s4.724s0.646s71.00x
💻 LocalNext.js (Turbopack)6.732s7.213s0.480s51.65x
💻 LocalNitro7.004s (-13.0% 🟢)7.515s (-11.8% 🟢)0.511s41.72x
💻 LocalExpress7.962s (-2.5%)8.519s (-5.6% 🟢)0.557s41.95x
🌐 MongoDBNext.js (Turbopack)9.845s10.347s0.502s32.41x
🐘 PostgresNitro51.308s (+5.8% 🔺)52.116s (+6.1% 🔺)0.808s112.58x
🐘 PostgresExpress51.596s (+2.2%)52.124s (+2.0%)0.528s112.65x
🐘 PostgresNext.js (Turbopack)53.052s53.112s0.060s113.01x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express3.070s (-25.8% 🟢)3.981s (-21.3% 🟢)0.911s81.00x
▲ VercelNitro3.728s (+13.0% 🔺)4.929s (+5.5% 🔺)1.201s71.21x
▲ VercelNext.js (Turbopack)3.910s (-17.0% 🟢)5.060s (-16.6% 🟢)1.149s61.27x

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

Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.111s (-37.2% 🟢)1.002s (~)0.009s (-22.5% 🟢)1.014s (~)0.903s101.00x
💻 LocalNext.js (Turbopack)0.119s1.001s0.010s1.016s0.897s101.07x
🌐 RedisNext.js (Turbopack)0.146s1.000s0.001s1.007s0.861s101.31x
💻 LocalExpress0.172s (~)1.002s (~)0.011s (-8.3% 🟢)1.016s (~)0.844s101.55x
🌐 MongoDBNext.js (Turbopack)0.492s0.953s0.002s1.008s0.516s104.43x
🐘 PostgresNext.js (Turbopack)1.435s1.625s0.001s2.013s0.578s1012.92x
🐘 PostgresExpress2.224s (+61.8% 🔺)2.818s (+69.3% 🔺)0.001s (-6.7% 🟢)3.015s (+49.8% 🔺)0.791s1020.02x
🐘 PostgresNitro2.286s (+82.0% 🔺)2.748s (+48.2% 🔺)0.001s (-14.3% 🟢)3.014s (+49.7% 🔺)0.728s1020.58x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)2.006s (-9.5% 🟢)2.652s (-10.0% 🟢)0.437s (+110.4% 🔺)3.667s (-1.7%)1.661s101.00x
▲ VercelExpress2.147s (-11.8% 🟢)2.782s (-6.1% 🟢)0.242s (+15.2% 🔺)3.673s (-2.5%)1.526s101.07x
▲ VercelNitro2.311s (+12.2% 🔺)2.586s (+8.1% 🔺)0.254s (+0.8%)3.467s (+7.7% 🔺)1.157s101.15x

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

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro11/12
🐘 PostgresNext.js (Turbopack)6/12
▲ VercelNitro7/12
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express💻 Local10/12
Next.js (Turbopack)🌐 Redis6/12
Nitro💻 Local10/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>

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
packages/core/src/events-consumer.tsImplements deferred orphaned event detection using setTimeout(0) with cancellation on new subscribes
packages/core/src/events-consumer.test.tsAdds unit tests for onUnconsumedEvent callback covering null events, orphaned events, and subscribe cancellation
packages/core/src/workflow.tsWires EventsConsumer with onUnconsumedEvent callback that rejects workflow via workflowDiscontinuation
packages/core/src/workflow.test.tsAdds integration tests for duplicate wait_completed, duplicate step_completed, and orphaned events blocking workflow execution
packages/core/src/workflow/sleep.test.tsUpdates 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 threadpackages/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>

@VaguelySeriousVaguelySerious left a comment

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.

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
ContributorAuthor

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.

pranaygpand 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 freeto 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

@pranaygp@TooTallNate@VaguelySerious
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
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

@pranaygppranaygp commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

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>
CopilotAI review requested due to automatic review settings February 13, 2026 23:57
@vercel

vercelBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-botBot commented Feb 13, 2026

Copy link
Copy Markdown

🦋 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
NameType
@workflow/corePatch
@workflow/errorsPatch
@workflow/buildersPatch
@workflow/cliPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/web-sharedPatch
workflowPatch
@workflow/world-localPatch
@workflow/world-postgresPatch
@workflow/world-vercelPatch
@workflow/astroPatch
@workflow/nestPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
@workflow/vitePatch
@workflow/world-testingPatch
@workflow/nuxtPatch

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

github-actionsBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

Some tests failed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production512038550
✅ 💻 Local Development532068600
✅ 📦 Local Production532068600
✅ 🐘 Local Postgres532068600
✅ 🪟 Windows470350
❌ 🌍 Community Worlds107439159
✅ 📋 Other129021150
Total2391432752709

❌ 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
AppPassedFailedSkipped
✅ astro4604
✅ example4604
✅ express4604
✅ fastify4604
✅ hono4604
✅ nextjs-turbopack4901
✅ nextjs-webpack4901
✅ nitro4604
✅ nuxt4604
✅ sveltekit4604
✅ vite4604
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack4703
❌ 🌍 Community Worlds
AppPassedFailedSkipped
✅ mongodb-dev300
✅ mongodb4703
✅ redis-dev300
✅ redis4703
✅ turso-dev300
❌ turso4433
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable4307
✅ e2e-local-postgres-nest-stable4307
✅ e2e-local-prod-nest-stable4307

📋 View full workflow run

@github-actions

github-actionsBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

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

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.026s (-22.8% 🟢)1.005s (~)0.979s101.00x
💻 LocalExpress0.031s (-3.4%)1.004s (~)0.973s101.20x
💻 LocalNext.js (Turbopack)0.039s1.006s0.967s101.48x
🌐 RedisNext.js (Turbopack)0.048s1.005s0.957s101.84x
🌐 MongoDBNext.js (Turbopack)0.088s1.007s0.919s103.40x
🐘 PostgresExpress0.105s (-8.1% 🟢)1.009s (~)0.904s104.06x
🐘 PostgresNitro0.479s (~)1.009s (~)0.530s1018.42x
🐘 PostgresNext.js (Turbopack)0.493s1.010s0.517s1018.97x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro0.582s (+10.0% 🔺)1.972s (+14.7% 🔺)1.390s101.00x
▲ VercelExpress0.604s (~)2.120s (+1.0%)1.516s101.04x
▲ VercelNext.js (Turbopack)0.637s (-15.7% 🟢)2.191s (-0.7%)1.554s101.10x

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

workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro1.072s (-3.2%)2.005s (~)0.933s101.00x
💻 LocalNext.js (Turbopack)1.086s2.005s0.920s101.01x
🌐 RedisNext.js (Turbopack)1.100s2.006s0.906s101.03x
💻 LocalExpress1.105s (~)2.005s (~)0.900s101.03x
🌐 MongoDBNext.js (Turbopack)1.305s2.008s0.703s101.22x
🐘 PostgresNext.js (Turbopack)2.270s2.813s0.543s102.12x
🐘 PostgresNitro2.354s (~)3.014s (~)0.659s102.20x
🐘 PostgresExpress2.492s (+25.5% 🔺)3.013s (+24.9% 🔺)0.521s102.33x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.232s (-18.2% 🟢)2.848s (-19.7% 🟢)0.616s101.00x
▲ VercelExpress2.283s (-54.2% 🟢)3.327s (-45.2% 🟢)1.044s101.02x
▲ VercelNext.js (Turbopack)2.377s (-54.2% 🟢)3.234s (-49.2% 🟢)0.857s101.06x

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

workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro10.551s (-2.5%)11.023s (~)0.472s31.00x
💻 LocalNext.js (Turbopack)10.651s11.022s0.371s31.01x
🌐 RedisNext.js (Turbopack)10.739s11.022s0.283s31.02x
💻 LocalExpress10.824s (~)11.022s (~)0.198s31.03x
🌐 MongoDBNext.js (Turbopack)12.306s13.024s0.718s31.17x
🐘 PostgresNext.js (Turbopack)15.242s16.046s0.804s21.44x
🐘 PostgresNitro20.210s (~)21.056s (~)0.846s21.92x
🐘 PostgresExpress20.376s (+32.6% 🔺)21.057s (+31.2% 🔺)0.681s21.93x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro16.978s (-1.4%)17.871s (~)0.893s21.00x
▲ VercelExpress17.579s (-2.9%)18.868s (-2.7%)1.289s21.04x
▲ VercelNext.js (Turbopack)17.705s (+1.3%)18.855s (~)1.150s21.04x

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

workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro26.775s (-2.7%)27.052s (-3.6%)0.277s31.00x
🌐 RedisNext.js (Turbopack)26.858s27.050s0.192s31.00x
💻 LocalNext.js (Turbopack)27.007s27.049s0.042s31.01x
💻 LocalExpress27.474s (~)28.051s (~)0.577s31.03x
🌐 MongoDBNext.js (Turbopack)30.506s31.042s0.536s21.14x
🐘 PostgresNext.js (Turbopack)37.629s38.093s0.464s21.41x
🐘 PostgresExpress50.226s (+33.2% 🔺)51.131s (+34.2% 🔺)0.905s21.88x
🐘 PostgresNitro50.492s (+11.0% 🔺)51.126s (+10.9% 🔺)0.634s21.89x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)44.103s (+0.5%)45.512s (+1.5%)1.409s21.00x
▲ VercelExpress45.438s (+5.7% 🔺)46.786s (+4.6%)1.348s21.03x
▲ VercelNitro48.197s (+2.2%)49.197s (+2.3%)0.999s21.09x

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

workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)54.359s55.096s0.737s21.00x
💻 LocalNitro55.645s (-3.1%)56.101s (-3.4%)0.455s21.02x
💻 LocalNext.js (Turbopack)56.337s57.101s0.764s21.04x
💻 LocalExpress57.272s (~)58.103s (~)0.831s21.05x
🌐 MongoDBNext.js (Turbopack)60.993s61.067s0.074s21.12x
🐘 PostgresNext.js (Turbopack)76.103s76.683s0.580s21.40x
🐘 PostgresNitro100.155s (+31.5% 🔺)100.214s (+30.7% 🔺)0.059s11.84x
🐘 PostgresExpress100.463s (+21.3% 🔺)101.232s (+20.9% 🔺)0.769s11.85x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express90.127s (+0.7%)90.819s (~)0.692s11.00x
▲ VercelNext.js (Turbopack)90.426s (~)91.209s (~)0.783s11.00x
▲ VercelNitro90.428s (+2.2%)91.592s (+2.4%)1.164s21.00x

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

Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)1.241s2.006s0.765s151.00x
💻 LocalNitro1.347s (-4.4%)2.005s (~)0.658s151.09x
💻 LocalNext.js (Turbopack)1.390s2.005s0.616s151.12x
💻 LocalExpress1.409s (-1.3%)2.006s (~)0.597s151.14x
🌐 MongoDBNext.js (Turbopack)2.139s3.008s0.869s101.72x
🐘 PostgresNext.js (Turbopack)2.152s3.014s0.862s101.73x
🐘 PostgresNitro2.170s (+12.1% 🔺)2.679s (~)0.510s121.75x
🐘 PostgresExpress2.493s (+2.4%)3.013s (~)0.520s102.01x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.461s (~)3.468s (+5.4% 🔺)1.007s91.00x
▲ VercelExpress2.718s (+8.9% 🔺)3.852s (+8.5% 🔺)1.133s81.10x
▲ VercelNext.js (Turbopack)3.021s (-12.3% 🟢)4.174s (-5.5% 🟢)1.153s81.23x

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

Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro2.278s (-13.0% 🟢)3.007s (~)0.728s101.00x
💻 LocalNext.js (Turbopack)2.406s3.007s0.601s101.06x
🌐 RedisNext.js (Turbopack)2.486s3.008s0.522s101.09x
💻 LocalExpress2.570s (-2.6%)3.008s (~)0.438s101.13x
🌐 MongoDBNext.js (Turbopack)4.706s5.177s0.471s62.07x
🐘 PostgresExpress7.952s (-15.1% 🟢)8.527s (-15.0% 🟢)0.576s43.49x
🐘 PostgresNitro10.828s (+12.2% 🔺)11.034s (+10.0% 🔺)0.206s34.75x
🐘 PostgresNext.js (Turbopack)11.555s12.033s0.478s35.07x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.935s (+6.4% 🔺)3.496s (-3.0%)0.561s91.00x
▲ VercelNext.js (Turbopack)2.946s (-19.9% 🟢)3.697s (-19.4% 🟢)0.751s91.00x
▲ VercelExpress4.071s (+44.0% 🔺)5.217s (+29.8% 🔺)1.146s61.39x

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

Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)4.088s4.582s0.494s71.00x
💻 LocalNitro6.301s (-18.7% 🟢)7.014s (-12.5% 🟢)0.713s51.54x
💻 LocalNext.js (Turbopack)6.918s7.515s0.597s41.69x
💻 LocalExpress7.310s (-5.0%)8.018s (~)0.708s41.79x
🌐 MongoDBNext.js (Turbopack)9.735s10.348s0.613s32.38x
🐘 PostgresExpress48.561s (+5.3% 🔺)49.117s (+4.2%)0.556s111.88x
🐘 PostgresNitro49.528s (+1.5%)50.127s (+2.0%)0.599s112.12x
🐘 PostgresNext.js (Turbopack)50.695s51.116s0.421s112.40x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.161s (-12.3% 🟢)4.394s (-10.0% 🟢)1.233s71.00x
▲ VercelNext.js (Turbopack)4.520s (+18.0% 🔺)5.941s (+15.7% 🔺)1.421s61.43x
▲ VercelExpress4.594s (+13.7% 🔺)5.580s (+7.6% 🔺)0.986s61.45x

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

Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)1.257s2.006s0.749s151.00x
💻 LocalNitro1.383s (-4.4%)2.005s (~)0.622s151.10x
💻 LocalExpress1.411s (-2.1%)2.006s (~)0.595s151.12x
💻 LocalNext.js (Turbopack)1.418s2.006s0.588s151.13x
🐘 PostgresNitro1.795s (-18.2% 🟢)2.011s (-22.6% 🟢)0.216s151.43x
🐘 PostgresExpress2.016s (-8.8% 🟢)2.513s (-6.3% 🟢)0.498s121.60x
🌐 MongoDBNext.js (Turbopack)2.156s3.007s0.851s101.71x
🐘 PostgresNext.js (Turbopack)2.205s2.596s0.391s121.75x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)2.376s (+4.4%)3.652s (+12.3% 🔺)1.276s91.00x
▲ VercelNitro2.423s (+2.8%)3.465s (+5.7% 🔺)1.042s91.02x
▲ VercelExpress2.466s (-0.8%)3.460s (-3.6%)0.994s91.04x

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

Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro2.392s (-13.5% 🟢)3.008s (~)0.616s101.00x
🌐 RedisNext.js (Turbopack)2.500s3.008s0.508s101.05x
💻 LocalNext.js (Turbopack)2.547s3.008s0.460s101.07x
💻 LocalExpress2.684s (-3.1%)3.007s (~)0.323s101.12x
🌐 MongoDBNext.js (Turbopack)4.678s5.177s0.499s61.96x
🐘 PostgresNitro11.136s (+1.0%)11.703s (+2.9%)0.567s34.66x
🐘 PostgresExpress11.259s (-9.2% 🟢)11.697s (-10.3% 🟢)0.438s34.71x
🐘 PostgresNext.js (Turbopack)11.602s12.365s0.763s34.85x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.466s (+0.6%)3.089s (-9.5% 🟢)0.623s101.00x
▲ VercelNext.js (Turbopack)2.614s (+0.9%)4.004s (+11.6% 🔺)1.390s81.06x
▲ VercelExpress3.000s (-15.7% 🟢)3.939s (-14.3% 🟢)0.940s81.22x

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

Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)4.078s4.724s0.646s71.00x
💻 LocalNext.js (Turbopack)6.732s7.213s0.480s51.65x
💻 LocalNitro7.004s (-13.0% 🟢)7.515s (-11.8% 🟢)0.511s41.72x
💻 LocalExpress7.962s (-2.5%)8.519s (-5.6% 🟢)0.557s41.95x
🌐 MongoDBNext.js (Turbopack)9.845s10.347s0.502s32.41x
🐘 PostgresNitro51.308s (+5.8% 🔺)52.116s (+6.1% 🔺)0.808s112.58x
🐘 PostgresExpress51.596s (+2.2%)52.124s (+2.0%)0.528s112.65x
🐘 PostgresNext.js (Turbopack)53.052s53.112s0.060s113.01x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express3.070s (-25.8% 🟢)3.981s (-21.3% 🟢)0.911s81.00x
▲ VercelNitro3.728s (+13.0% 🔺)4.929s (+5.5% 🔺)1.201s71.21x
▲ VercelNext.js (Turbopack)3.910s (-17.0% 🟢)5.060s (-16.6% 🟢)1.149s61.27x

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

Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.111s (-37.2% 🟢)1.002s (~)0.009s (-22.5% 🟢)1.014s (~)0.903s101.00x
💻 LocalNext.js (Turbopack)0.119s1.001s0.010s1.016s0.897s101.07x
🌐 RedisNext.js (Turbopack)0.146s1.000s0.001s1.007s0.861s101.31x
💻 LocalExpress0.172s (~)1.002s (~)0.011s (-8.3% 🟢)1.016s (~)0.844s101.55x
🌐 MongoDBNext.js (Turbopack)0.492s0.953s0.002s1.008s0.516s104.43x
🐘 PostgresNext.js (Turbopack)1.435s1.625s0.001s2.013s0.578s1012.92x
🐘 PostgresExpress2.224s (+61.8% 🔺)2.818s (+69.3% 🔺)0.001s (-6.7% 🟢)3.015s (+49.8% 🔺)0.791s1020.02x
🐘 PostgresNitro2.286s (+82.0% 🔺)2.748s (+48.2% 🔺)0.001s (-14.3% 🟢)3.014s (+49.7% 🔺)0.728s1020.58x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)2.006s (-9.5% 🟢)2.652s (-10.0% 🟢)0.437s (+110.4% 🔺)3.667s (-1.7%)1.661s101.00x
▲ VercelExpress2.147s (-11.8% 🟢)2.782s (-6.1% 🟢)0.242s (+15.2% 🔺)3.673s (-2.5%)1.526s101.07x
▲ VercelNitro2.311s (+12.2% 🔺)2.586s (+8.1% 🔺)0.254s (+0.8%)3.467s (+7.7% 🔺)1.157s101.15x

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

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro11/12
🐘 PostgresNext.js (Turbopack)6/12
▲ VercelNitro7/12
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express💻 Local10/12
Next.js (Turbopack)🌐 Redis6/12
Nitro💻 Local10/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>

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
packages/core/src/events-consumer.tsImplements deferred orphaned event detection using setTimeout(0) with cancellation on new subscribes
packages/core/src/events-consumer.test.tsAdds unit tests for onUnconsumedEvent callback covering null events, orphaned events, and subscribe cancellation
packages/core/src/workflow.tsWires EventsConsumer with onUnconsumedEvent callback that rejects workflow via workflowDiscontinuation
packages/core/src/workflow.test.tsAdds integration tests for duplicate wait_completed, duplicate step_completed, and orphaned events blocking workflow execution
packages/core/src/workflow/sleep.test.tsUpdates 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 threadpackages/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>

@VaguelySeriousVaguelySerious left a comment

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.

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
ContributorAuthor

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.

pranaygpand 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 freeto 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

@pranaygp@TooTallNate@VaguelySerious
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
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

@pranaygppranaygp commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

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>
CopilotAI review requested due to automatic review settings February 13, 2026 23:57
@vercel

vercelBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-botBot commented Feb 13, 2026

Copy link
Copy Markdown

🦋 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
NameType
@workflow/corePatch
@workflow/errorsPatch
@workflow/buildersPatch
@workflow/cliPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/web-sharedPatch
workflowPatch
@workflow/world-localPatch
@workflow/world-postgresPatch
@workflow/world-vercelPatch
@workflow/astroPatch
@workflow/nestPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
@workflow/vitePatch
@workflow/world-testingPatch
@workflow/nuxtPatch

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

github-actionsBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

Some tests failed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production512038550
✅ 💻 Local Development532068600
✅ 📦 Local Production532068600
✅ 🐘 Local Postgres532068600
✅ 🪟 Windows470350
❌ 🌍 Community Worlds107439159
✅ 📋 Other129021150
Total2391432752709

❌ 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
AppPassedFailedSkipped
✅ astro4604
✅ example4604
✅ express4604
✅ fastify4604
✅ hono4604
✅ nextjs-turbopack4901
✅ nextjs-webpack4901
✅ nitro4604
✅ nuxt4604
✅ sveltekit4604
✅ vite4604
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable4307
✅ express-stable4307
✅ fastify-stable4307
✅ hono-stable4307
✅ nextjs-turbopack-canary4703
✅ nextjs-turbopack-stable4703
✅ nextjs-webpack-canary4703
✅ nextjs-webpack-stable4703
✅ nitro-stable4307
✅ nuxt-stable4307
✅ sveltekit-stable4307
✅ vite-stable4307
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack4703
❌ 🌍 Community Worlds
AppPassedFailedSkipped
✅ mongodb-dev300
✅ mongodb4703
✅ redis-dev300
✅ redis4703
✅ turso-dev300
❌ turso4433
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable4307
✅ e2e-local-postgres-nest-stable4307
✅ e2e-local-prod-nest-stable4307

📋 View full workflow run

@github-actions

github-actionsBot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

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

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.026s (-22.8% 🟢)1.005s (~)0.979s101.00x
💻 LocalExpress0.031s (-3.4%)1.004s (~)0.973s101.20x
💻 LocalNext.js (Turbopack)0.039s1.006s0.967s101.48x
🌐 RedisNext.js (Turbopack)0.048s1.005s0.957s101.84x
🌐 MongoDBNext.js (Turbopack)0.088s1.007s0.919s103.40x
🐘 PostgresExpress0.105s (-8.1% 🟢)1.009s (~)0.904s104.06x
🐘 PostgresNitro0.479s (~)1.009s (~)0.530s1018.42x
🐘 PostgresNext.js (Turbopack)0.493s1.010s0.517s1018.97x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro0.582s (+10.0% 🔺)1.972s (+14.7% 🔺)1.390s101.00x
▲ VercelExpress0.604s (~)2.120s (+1.0%)1.516s101.04x
▲ VercelNext.js (Turbopack)0.637s (-15.7% 🟢)2.191s (-0.7%)1.554s101.10x

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

workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro1.072s (-3.2%)2.005s (~)0.933s101.00x
💻 LocalNext.js (Turbopack)1.086s2.005s0.920s101.01x
🌐 RedisNext.js (Turbopack)1.100s2.006s0.906s101.03x
💻 LocalExpress1.105s (~)2.005s (~)0.900s101.03x
🌐 MongoDBNext.js (Turbopack)1.305s2.008s0.703s101.22x
🐘 PostgresNext.js (Turbopack)2.270s2.813s0.543s102.12x
🐘 PostgresNitro2.354s (~)3.014s (~)0.659s102.20x
🐘 PostgresExpress2.492s (+25.5% 🔺)3.013s (+24.9% 🔺)0.521s102.33x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.232s (-18.2% 🟢)2.848s (-19.7% 🟢)0.616s101.00x
▲ VercelExpress2.283s (-54.2% 🟢)3.327s (-45.2% 🟢)1.044s101.02x
▲ VercelNext.js (Turbopack)2.377s (-54.2% 🟢)3.234s (-49.2% 🟢)0.857s101.06x

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

workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro10.551s (-2.5%)11.023s (~)0.472s31.00x
💻 LocalNext.js (Turbopack)10.651s11.022s0.371s31.01x
🌐 RedisNext.js (Turbopack)10.739s11.022s0.283s31.02x
💻 LocalExpress10.824s (~)11.022s (~)0.198s31.03x
🌐 MongoDBNext.js (Turbopack)12.306s13.024s0.718s31.17x
🐘 PostgresNext.js (Turbopack)15.242s16.046s0.804s21.44x
🐘 PostgresNitro20.210s (~)21.056s (~)0.846s21.92x
🐘 PostgresExpress20.376s (+32.6% 🔺)21.057s (+31.2% 🔺)0.681s21.93x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro16.978s (-1.4%)17.871s (~)0.893s21.00x
▲ VercelExpress17.579s (-2.9%)18.868s (-2.7%)1.289s21.04x
▲ VercelNext.js (Turbopack)17.705s (+1.3%)18.855s (~)1.150s21.04x

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

workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro26.775s (-2.7%)27.052s (-3.6%)0.277s31.00x
🌐 RedisNext.js (Turbopack)26.858s27.050s0.192s31.00x
💻 LocalNext.js (Turbopack)27.007s27.049s0.042s31.01x
💻 LocalExpress27.474s (~)28.051s (~)0.577s31.03x
🌐 MongoDBNext.js (Turbopack)30.506s31.042s0.536s21.14x
🐘 PostgresNext.js (Turbopack)37.629s38.093s0.464s21.41x
🐘 PostgresExpress50.226s (+33.2% 🔺)51.131s (+34.2% 🔺)0.905s21.88x
🐘 PostgresNitro50.492s (+11.0% 🔺)51.126s (+10.9% 🔺)0.634s21.89x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)44.103s (+0.5%)45.512s (+1.5%)1.409s21.00x
▲ VercelExpress45.438s (+5.7% 🔺)46.786s (+4.6%)1.348s21.03x
▲ VercelNitro48.197s (+2.2%)49.197s (+2.3%)0.999s21.09x

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

workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)54.359s55.096s0.737s21.00x
💻 LocalNitro55.645s (-3.1%)56.101s (-3.4%)0.455s21.02x
💻 LocalNext.js (Turbopack)56.337s57.101s0.764s21.04x
💻 LocalExpress57.272s (~)58.103s (~)0.831s21.05x
🌐 MongoDBNext.js (Turbopack)60.993s61.067s0.074s21.12x
🐘 PostgresNext.js (Turbopack)76.103s76.683s0.580s21.40x
🐘 PostgresNitro100.155s (+31.5% 🔺)100.214s (+30.7% 🔺)0.059s11.84x
🐘 PostgresExpress100.463s (+21.3% 🔺)101.232s (+20.9% 🔺)0.769s11.85x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express90.127s (+0.7%)90.819s (~)0.692s11.00x
▲ VercelNext.js (Turbopack)90.426s (~)91.209s (~)0.783s11.00x
▲ VercelNitro90.428s (+2.2%)91.592s (+2.4%)1.164s21.00x

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

Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)1.241s2.006s0.765s151.00x
💻 LocalNitro1.347s (-4.4%)2.005s (~)0.658s151.09x
💻 LocalNext.js (Turbopack)1.390s2.005s0.616s151.12x
💻 LocalExpress1.409s (-1.3%)2.006s (~)0.597s151.14x
🌐 MongoDBNext.js (Turbopack)2.139s3.008s0.869s101.72x
🐘 PostgresNext.js (Turbopack)2.152s3.014s0.862s101.73x
🐘 PostgresNitro2.170s (+12.1% 🔺)2.679s (~)0.510s121.75x
🐘 PostgresExpress2.493s (+2.4%)3.013s (~)0.520s102.01x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.461s (~)3.468s (+5.4% 🔺)1.007s91.00x
▲ VercelExpress2.718s (+8.9% 🔺)3.852s (+8.5% 🔺)1.133s81.10x
▲ VercelNext.js (Turbopack)3.021s (-12.3% 🟢)4.174s (-5.5% 🟢)1.153s81.23x

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

Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro2.278s (-13.0% 🟢)3.007s (~)0.728s101.00x
💻 LocalNext.js (Turbopack)2.406s3.007s0.601s101.06x
🌐 RedisNext.js (Turbopack)2.486s3.008s0.522s101.09x
💻 LocalExpress2.570s (-2.6%)3.008s (~)0.438s101.13x
🌐 MongoDBNext.js (Turbopack)4.706s5.177s0.471s62.07x
🐘 PostgresExpress7.952s (-15.1% 🟢)8.527s (-15.0% 🟢)0.576s43.49x
🐘 PostgresNitro10.828s (+12.2% 🔺)11.034s (+10.0% 🔺)0.206s34.75x
🐘 PostgresNext.js (Turbopack)11.555s12.033s0.478s35.07x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.935s (+6.4% 🔺)3.496s (-3.0%)0.561s91.00x
▲ VercelNext.js (Turbopack)2.946s (-19.9% 🟢)3.697s (-19.4% 🟢)0.751s91.00x
▲ VercelExpress4.071s (+44.0% 🔺)5.217s (+29.8% 🔺)1.146s61.39x

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

Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)4.088s4.582s0.494s71.00x
💻 LocalNitro6.301s (-18.7% 🟢)7.014s (-12.5% 🟢)0.713s51.54x
💻 LocalNext.js (Turbopack)6.918s7.515s0.597s41.69x
💻 LocalExpress7.310s (-5.0%)8.018s (~)0.708s41.79x
🌐 MongoDBNext.js (Turbopack)9.735s10.348s0.613s32.38x
🐘 PostgresExpress48.561s (+5.3% 🔺)49.117s (+4.2%)0.556s111.88x
🐘 PostgresNitro49.528s (+1.5%)50.127s (+2.0%)0.599s112.12x
🐘 PostgresNext.js (Turbopack)50.695s51.116s0.421s112.40x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.161s (-12.3% 🟢)4.394s (-10.0% 🟢)1.233s71.00x
▲ VercelNext.js (Turbopack)4.520s (+18.0% 🔺)5.941s (+15.7% 🔺)1.421s61.43x
▲ VercelExpress4.594s (+13.7% 🔺)5.580s (+7.6% 🔺)0.986s61.45x

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

Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)1.257s2.006s0.749s151.00x
💻 LocalNitro1.383s (-4.4%)2.005s (~)0.622s151.10x
💻 LocalExpress1.411s (-2.1%)2.006s (~)0.595s151.12x
💻 LocalNext.js (Turbopack)1.418s2.006s0.588s151.13x
🐘 PostgresNitro1.795s (-18.2% 🟢)2.011s (-22.6% 🟢)0.216s151.43x
🐘 PostgresExpress2.016s (-8.8% 🟢)2.513s (-6.3% 🟢)0.498s121.60x
🌐 MongoDBNext.js (Turbopack)2.156s3.007s0.851s101.71x
🐘 PostgresNext.js (Turbopack)2.205s2.596s0.391s121.75x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)2.376s (+4.4%)3.652s (+12.3% 🔺)1.276s91.00x
▲ VercelNitro2.423s (+2.8%)3.465s (+5.7% 🔺)1.042s91.02x
▲ VercelExpress2.466s (-0.8%)3.460s (-3.6%)0.994s91.04x

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

Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro2.392s (-13.5% 🟢)3.008s (~)0.616s101.00x
🌐 RedisNext.js (Turbopack)2.500s3.008s0.508s101.05x
💻 LocalNext.js (Turbopack)2.547s3.008s0.460s101.07x
💻 LocalExpress2.684s (-3.1%)3.007s (~)0.323s101.12x
🌐 MongoDBNext.js (Turbopack)4.678s5.177s0.499s61.96x
🐘 PostgresNitro11.136s (+1.0%)11.703s (+2.9%)0.567s34.66x
🐘 PostgresExpress11.259s (-9.2% 🟢)11.697s (-10.3% 🟢)0.438s34.71x
🐘 PostgresNext.js (Turbopack)11.602s12.365s0.763s34.85x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.466s (+0.6%)3.089s (-9.5% 🟢)0.623s101.00x
▲ VercelNext.js (Turbopack)2.614s (+0.9%)4.004s (+11.6% 🔺)1.390s81.06x
▲ VercelExpress3.000s (-15.7% 🟢)3.939s (-14.3% 🟢)0.940s81.22x

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

Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🌐 Redis🥇 Next.js (Turbopack)4.078s4.724s0.646s71.00x
💻 LocalNext.js (Turbopack)6.732s7.213s0.480s51.65x
💻 LocalNitro7.004s (-13.0% 🟢)7.515s (-11.8% 🟢)0.511s41.72x
💻 LocalExpress7.962s (-2.5%)8.519s (-5.6% 🟢)0.557s41.95x
🌐 MongoDBNext.js (Turbopack)9.845s10.347s0.502s32.41x
🐘 PostgresNitro51.308s (+5.8% 🔺)52.116s (+6.1% 🔺)0.808s112.58x
🐘 PostgresExpress51.596s (+2.2%)52.124s (+2.0%)0.528s112.65x
🐘 PostgresNext.js (Turbopack)53.052s53.112s0.060s113.01x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express3.070s (-25.8% 🟢)3.981s (-21.3% 🟢)0.911s81.00x
▲ VercelNitro3.728s (+13.0% 🔺)4.929s (+5.5% 🔺)1.201s71.21x
▲ VercelNext.js (Turbopack)3.910s (-17.0% 🟢)5.060s (-16.6% 🟢)1.149s61.27x

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

Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.111s (-37.2% 🟢)1.002s (~)0.009s (-22.5% 🟢)1.014s (~)0.903s101.00x
💻 LocalNext.js (Turbopack)0.119s1.001s0.010s1.016s0.897s101.07x
🌐 RedisNext.js (Turbopack)0.146s1.000s0.001s1.007s0.861s101.31x
💻 LocalExpress0.172s (~)1.002s (~)0.011s (-8.3% 🟢)1.016s (~)0.844s101.55x
🌐 MongoDBNext.js (Turbopack)0.492s0.953s0.002s1.008s0.516s104.43x
🐘 PostgresNext.js (Turbopack)1.435s1.625s0.001s2.013s0.578s1012.92x
🐘 PostgresExpress2.224s (+61.8% 🔺)2.818s (+69.3% 🔺)0.001s (-6.7% 🟢)3.015s (+49.8% 🔺)0.791s1020.02x
🐘 PostgresNitro2.286s (+82.0% 🔺)2.748s (+48.2% 🔺)0.001s (-14.3% 🟢)3.014s (+49.7% 🔺)0.728s1020.58x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)2.006s (-9.5% 🟢)2.652s (-10.0% 🟢)0.437s (+110.4% 🔺)3.667s (-1.7%)1.661s101.00x
▲ VercelExpress2.147s (-11.8% 🟢)2.782s (-6.1% 🟢)0.242s (+15.2% 🔺)3.673s (-2.5%)1.526s101.07x
▲ VercelNitro2.311s (+12.2% 🔺)2.586s (+8.1% 🔺)0.254s (+0.8%)3.467s (+7.7% 🔺)1.157s101.15x

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

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro11/12
🐘 PostgresNext.js (Turbopack)6/12
▲ VercelNitro7/12
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express💻 Local10/12
Next.js (Turbopack)🌐 Redis6/12
Nitro💻 Local10/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>

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
packages/core/src/events-consumer.tsImplements deferred orphaned event detection using setTimeout(0) with cancellation on new subscribes
packages/core/src/events-consumer.test.tsAdds unit tests for onUnconsumedEvent callback covering null events, orphaned events, and subscribe cancellation
packages/core/src/workflow.tsWires EventsConsumer with onUnconsumedEvent callback that rejects workflow via workflowDiscontinuation
packages/core/src/workflow.test.tsAdds integration tests for duplicate wait_completed, duplicate step_completed, and orphaned events blocking workflow execution
packages/core/src/workflow/sleep.test.tsUpdates 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 threadpackages/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>

@VaguelySeriousVaguelySerious left a comment

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.

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
ContributorAuthor

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.

pranaygpand 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 freeto 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

@pranaygp@TooTallNate@VaguelySerious