Skip to content

fix(core): chain unconsumed event check onto promiseQueue to prevent false positives#1254

Merged
TooTallNate merged 5 commits into
mainfrom
fix/unconsumed-event-false-positive
Mar 4, 2026
Merged

fix(core): chain unconsumed event check onto promiseQueue to prevent false positives#1254
TooTallNate merged 5 commits into
mainfrom
fix/unconsumed-event-false-positive

Conversation

@TooTallNate
Copy link
Copy Markdown
Member

Summary

Fixes a production bug where the EventsConsumer's unconsumed event check falsely flagged valid step_created events as orphaned when parallel steps performed async deserialization (e.g., encryption/decryption).

Problem

When parallel steps A and B completed, their hydrateStepReturnValue calls did real async work via the promiseQueue. The EventsConsumer's setTimeout(0) unconsumed check fired before the promise chain resolved the step results and triggered the next subscribe() call. This caused step C's step_created event to be falsely flagged:

WorkflowRuntimeError: Unconsumed event in event log: eventType=step_created,
correlationId=step_01KJV5SWK73FSTW7X3BTVT7821

Event log pattern:

step_created(A), step_created(B),  ← parallel
step_completed(B), step_completed(A),
step_created(C),                    ← sequential, flagged as orphaned

Fix

  • Chain the unconsumed event check onto the promiseQueue via a new getPromiseQueue option on EventsConsumerOptions, so it only fires after all pending async work (deserialization/decryption) completes
  • Use process.nextTick (not setTimeout) after the queue drains to avoid keeping the event loop alive
  • Version-based cancellation replaces clearTimeout since the check is now promise-based
  • workflow.ts uses a getter/setter on the context to keep getPromiseQueue in sync as the queue is mutated

Test plan

  • Reproduction test (workflow.test.ts): parallel steps A+B with 10ms mock deserialization delay, followed by sequential step C. Previously failed with the production error. Now passes.
  • All 147 tests pass across 6 test files (events-consumer, workflow, step, hook, sleep, async-deserialization-ordering)
  • Build clean

…false positives

The EventsConsumer's unconsumed event check (setTimeout(0)) was racing
against the promiseQueue's async deserialization. When parallel steps
completed and their hydrateStepReturnValue did real async work (e.g.,
decryption), the setTimeout(0) fired before the promise chain resolved
the step results and triggered the next subscribe() call. This caused
step_created events for sequential steps to be falsely flagged as
unconsumed/orphaned.

Fix: chain the unconsumed check onto the promiseQueue via getPromiseQueue()
so it only fires after all pending async work completes. Use
process.nextTick (not setTimeout) after the queue drains to give
synchronous subscribe() calls from resolved user code a chance to cancel.
Version-based cancellation replaces clearTimeout since the check is now
promise-based.

Adds getPromiseQueue option to EventsConsumerOptions. The workflow.ts
context uses a getter/setter to keep the promiseQueue holder in sync.

Reproduction test: parallel steps A+B with 10ms mock deserialization
delay, followed by sequential step C. Previously failed with
'Unconsumed event: step_created(C)'. Now passes.
@TooTallNate TooTallNate requested a review from a team as a code owner March 4, 2026 04:38
Copilot AI review requested due to automatic review settings March 4, 2026 04:38
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Mar 4, 2026

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 4, 2026

🦋 Changeset detected

Latest commit: 1bb2a66

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

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

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

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 4, 2026

🧪 E2E Test Results

Some tests failed

Summary

Passed Failed Skipped Total
✅ ▲ Vercel Production 538 0 67 605
✅ 💻 Local Development 576 0 84 660
✅ 📦 Local Production 576 0 84 660
✅ 🐘 Local Postgres 576 0 84 660
✅ 🪟 Windows 52 0 3 55
❌ 🌍 Community Worlds 117 48 15 180
✅ 📋 Other 138 0 27 165
Total 2573 48 364 2985

❌ Failed Tests

🌍 Community Worlds (48 failed)

turso (48 failed):

  • addTenWorkflow
  • addTenWorkflow
  • wellKnownAgentWorkflow (.well-known/agent)
  • should work with react rendering in step
  • promiseAllWorkflow
  • promiseRaceWorkflow
  • promiseAnyWorkflow
  • importedStepOnlyWorkflow
  • 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
  • hookDisposeTestWorkflow - hook token reuse after explicit disposal while workflow still running
  • 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
  • cancelRun - cancelling a running workflow
  • cancelRun via CLI - cancelling a running workflow
  • pages router addTenWorkflow via pages router
  • pages router promiseAllWorkflow via pages router
  • pages router sleepingWorkflow via pages router

Details by Category

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

📋 View full workflow run

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 4, 2026

📊 Benchmark Results

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

workflow with no steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Express 0.033s (+0.9%) 1.005s (~) 0.972s 10 1.00x
💻 Local Nitro 0.033s (+3.1%) 1.005s (~) 0.972s 10 1.02x
🐘 Postgres Express 0.054s (+25.3% 🔺) 1.011s (~) 0.956s 10 1.67x
🐘 Postgres Nitro 0.055s (+3.0%) 1.011s (~) 0.956s 10 1.68x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 0.424s (-35.9% 🟢) 1.844s (-4.6%) 1.420s 10 1.00x
▲ Vercel Nitro 0.474s (-20.9% 🟢) 1.738s (-12.2% 🟢) 1.264s 10 1.12x
▲ Vercel Express 0.479s (+13.6% 🔺) 2.031s (+8.6% 🔺) 1.553s 10 1.13x

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

workflow with 1 step

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Nitro 1.101s (~) 2.005s (~) 0.904s 10 1.00x
💻 Local Express 1.103s (~) 2.006s (~) 0.903s 10 1.00x
🐘 Postgres Express 1.126s (+2.7%) 2.012s (~) 0.886s 10 1.02x
🐘 Postgres Nitro 1.130s (+0.6%) 2.011s (~) 0.880s 10 1.03x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 1.979s (-9.5% 🟢) 2.974s (-13.9% 🟢) 0.995s 10 1.00x
▲ Vercel Next.js (Turbopack) 2.009s (-0.6%) 3.175s (+10.5% 🔺) 1.166s 10 1.02x
▲ Vercel Express 2.205s (-16.5% 🟢) 3.407s (-8.1% 🟢) 1.203s 10 1.11x

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

workflow with 10 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Nitro 10.769s (~) 11.023s (~) 0.253s 3 1.00x
💻 Local Express 10.780s (~) 11.024s (~) 0.244s 3 1.00x
🐘 Postgres Nitro 10.814s (~) 11.039s (~) 0.225s 3 1.00x
🐘 Postgres Express 10.814s (+1.2%) 11.040s (~) 0.225s 3 1.00x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 16.934s (-94.8% 🟢) 18.082s (-94.4% 🟢) 1.148s 2 1.00x
▲ Vercel Nitro 17.810s (+8.7% 🔺) 18.906s (+6.1% 🔺) 1.096s 2 1.05x
▲ Vercel Next.js (Turbopack) 18.698s (-7.6% 🟢) 19.479s (-8.3% 🟢) 0.781s 2 1.10x

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

workflow with 25 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 26.869s (~) 27.053s (~) 0.184s 3 1.00x
🐘 Postgres Express 26.981s (+1.5%) 27.064s (~) 0.083s 3 1.00x
💻 Local Nitro 27.184s (~) 28.053s (~) 0.869s 3 1.01x
💻 Local Express 27.217s (~) 28.050s (~) 0.833s 3 1.01x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 43.014s (-2.8%) 44.440s (-2.1%) 1.425s 2 1.00x
▲ Vercel Nitro 43.525s (-4.9%) 44.531s (-5.3% 🟢) 1.006s 2 1.01x
▲ Vercel Next.js (Turbopack) 45.175s (+2.3%) 46.495s (+3.3%) 1.321s 2 1.05x

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

workflow with 50 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 53.729s (+1.0%) 54.103s (~) 0.374s 2 1.00x
🐘 Postgres Nitro 53.816s (~) 54.093s (~) 0.277s 2 1.00x
💻 Local Nitro 56.092s (~) 56.601s (+0.9%) 0.509s 2 1.04x
💻 Local Express 56.136s (~) 57.102s (+1.8%) 0.966s 2 1.04x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 91.044s (-8.5% 🟢) 92.495s (-8.4% 🟢) 1.451s 1 1.00x
▲ Vercel Nitro 92.696s (-5.4% 🟢) 93.448s (-5.2% 🟢) 0.752s 1 1.02x
▲ Vercel Next.js (Turbopack) 97.433s (~) 98.935s (~) 1.502s 1 1.07x

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

Promise.all with 10 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 1.342s (-2.1%) 2.011s (~) 0.669s 15 1.00x
🐘 Postgres Express 1.369s (+5.4% 🔺) 2.010s (~) 0.641s 15 1.02x
💻 Local Nitro 1.420s (~) 2.005s (~) 0.585s 15 1.06x
💻 Local Express 1.439s (~) 2.005s (~) 0.566s 15 1.07x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 2.061s (-13.6% 🟢) 2.866s (-16.2% 🟢) 0.805s 11 1.00x
▲ Vercel Express 2.182s (-1.5%) 3.439s (+11.7% 🔺) 1.257s 9 1.06x
▲ Vercel Next.js (Turbopack) 2.388s (-3.0%) 3.427s (+2.0%) 1.038s 9 1.16x

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

Promise.all with 25 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 1.987s (+7.9% 🔺) 2.513s (+8.3% 🔺) 0.526s 12 1.00x
🐘 Postgres Nitro 2.057s (+0.9%) 2.596s (+3.3%) 0.539s 12 1.04x
💻 Local Nitro 2.644s (~) 3.007s (~) 0.364s 10 1.33x
💻 Local Express 2.675s (+2.0%) 3.007s (~) 0.332s 10 1.35x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 2.807s (+8.5% 🔺) 3.553s (-0.7%) 0.746s 9 1.00x
▲ Vercel Express 2.815s (-17.5% 🟢) 3.604s (-18.6% 🟢) 0.789s 9 1.00x
▲ Vercel Next.js (Turbopack) 3.037s (+22.0% 🔺) 4.100s (+21.3% 🔺) 1.064s 8 1.08x

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

Promise.all with 50 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 3.545s (-6.7% 🟢) 4.452s (~) 0.906s 7 1.00x
🐘 Postgres Express 3.876s (+43.4% 🔺) 4.458s (+24.8% 🔺) 0.582s 7 1.09x
💻 Local Nitro 7.516s (-3.9%) 8.020s (-3.0%) 0.505s 4 2.12x
💻 Local Express 7.764s (+0.5%) 8.019s (~) 0.254s 4 2.19x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 3.225s (-4.3%) 4.312s (-4.4%) 1.086s 7 1.00x
▲ Vercel Express 3.293s (+13.7% 🔺) 4.304s (+3.5%) 1.011s 8 1.02x
▲ Vercel Nitro 3.965s (+7.9% 🔺) 5.317s (+8.9% 🔺) 1.353s 6 1.23x

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

Promise.race with 10 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 1.362s (-1.6%) 2.010s (~) 0.648s 15 1.00x
🐘 Postgres Express 1.380s (+5.4% 🔺) 2.011s (~) 0.631s 15 1.01x
💻 Local Nitro 1.436s (~) 2.005s (~) 0.568s 15 1.05x
💻 Local Express 1.449s (+1.3%) 2.004s (~) 0.555s 15 1.06x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 2.038s (-98.7% 🟢) 3.008s (-98.1% 🟢) 0.970s 10 1.00x
▲ Vercel Next.js (Turbopack) 2.191s (+7.9% 🔺) 3.411s (+1.9%) 1.220s 9 1.07x
▲ Vercel Express 3.587s (+75.0% 🔺) 4.679s (+53.3% 🔺) 1.092s 7 1.76x

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

Promise.race with 25 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 2.030s (-2.4%) 2.512s (-6.3% 🟢) 0.483s 12 1.00x
🐘 Postgres Express 2.058s (+15.5% 🔺) 2.599s (+13.1% 🔺) 0.541s 12 1.01x
💻 Local Nitro 2.764s (-0.7%) 3.008s (~) 0.244s 10 1.36x
💻 Local Express 2.810s (+2.7%) 3.009s (~) 0.199s 10 1.38x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 2.312s (-7.2% 🟢) 3.129s (-8.6% 🟢) 0.817s 10 1.00x
▲ Vercel Next.js (Turbopack) 2.925s (+10.5% 🔺) 3.911s (+12.2% 🔺) 0.986s 8 1.27x
▲ Vercel Express 3.183s (+18.5% 🔺) 4.233s (+20.7% 🔺) 1.050s 8 1.38x

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

Promise.race with 50 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 3.533s (-20.5% 🟢) 4.448s (-14.4% 🟢) 0.915s 7 1.00x
🐘 Postgres Express 3.590s (+15.3% 🔺) 4.398s (+12.9% 🔺) 0.808s 8 1.02x
💻 Local Nitro 8.225s (-1.8%) 9.021s (~) 0.796s 4 2.33x
💻 Local Express 8.590s (~) 9.019s (~) 0.429s 4 2.43x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 2.898s (-9.6% 🟢) 3.816s (-10.2% 🟢) 0.918s 8 1.00x
▲ Vercel Nitro 2.904s (-9.0% 🟢) 4.042s (-5.4% 🟢) 1.138s 8 1.00x
▲ Vercel Next.js (Turbopack) 3.865s (+7.7% 🔺) 4.880s (+6.8% 🔺) 1.015s 7 1.33x

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

Stream Benchmarks (includes TTFB metrics)
workflow with stream

💻 Local Development

World Framework Workflow Time TTFB Slurp Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Express 0.173s (+1.1%) 1.002s (~) 0.012s (+2.5%) 1.017s (~) 0.844s 10 1.00x
💻 Local Nitro 0.173s (-0.6%) 1.003s (~) 0.011s (-0.9%) 1.017s (~) 0.844s 10 1.00x
🐘 Postgres Express 0.183s (+25.1% 🔺) 0.995s (~) 0.001s (~) 1.011s (~) 0.828s 10 1.05x
🐘 Postgres Nitro 0.205s (+7.8% 🔺) 0.994s (~) 0.002s (+28.6% 🔺) 1.013s (~) 0.808s 10 1.18x
💻 Local Next.js (Turbopack) ⚠️ missing - - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - - -

▲ Production (Vercel)

World Framework Workflow Time TTFB Slurp Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 1.469s (-8.1% 🟢) 2.072s (-15.0% 🟢) 0.136s (+3.1%) 32.494s (+970.0% 🔺) 31.025s 10 1.00x
▲ Vercel Express 1.538s (-6.3% 🟢) 1.972s (-1.4%) 0.132s (+19.5% 🔺) 2.549s (~) 1.011s 10 1.05x
▲ Vercel Next.js (Turbopack) 1.662s (+6.4% 🔺) 2.220s (+2.4%) 0.149s (-57.5% 🟢) 2.844s (-2.3%) 1.182s 10 1.13x

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

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World 🥇 Fastest Framework Wins
💻 Local Nitro 10/12
🐘 Postgres Nitro 7/12
▲ Vercel Nitro 6/12
Fastest World by Framework

Winner determined by most benchmark wins

Framework 🥇 Fastest World Wins
Express 🐘 Postgres 6/12
Next.js (Turbopack) ▲ Vercel 12/12
Nitro 🐘 Postgres 7/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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a production timing race in EventsConsumer where the “unconsumed event” orphan check could run before pending async hydration/deserialization work completed, causing valid step_created events (especially after parallel steps) to be falsely flagged as orphaned.

Changes:

  • Add getPromiseQueue() to EventsConsumerOptions and chain the unconsumed-event check onto the current promiseQueue to ensure pending async work completes first.
  • Update runWorkflow to expose a mutable promiseQueue reference via a getter/setter so EventsConsumer always sees the latest queue state.
  • Add/adjust tests to reproduce the parallel-steps + async-deserialization race and validate the corrected ordering/behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/core/src/events-consumer.ts Defers unconsumed-event check by chaining onto the promise queue and uses version-based cancellation.
packages/core/src/workflow.ts Introduces a mutable promiseQueue holder and wires EventsConsumer to the live queue via getPromiseQueue.
packages/core/src/events-consumer.test.ts Updates unit tests to reflect promise-queue/nextTick-based deferral semantics.
packages/core/src/workflow.test.ts Adds regression tests reproducing the production false-positive scenario (parallel steps + async hydration).
packages/core/src/workflow/sleep.test.ts Updates test harness to pass getPromiseQueue option.
packages/core/src/workflow/hook.test.ts Updates test harness to pass getPromiseQueue option.
packages/core/src/step.test.ts Updates test harness to pass getPromiseQueue option.
packages/core/src/async-deserialization-ordering.test.ts Updates test harness to pass getPromiseQueue option.

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

You can also share your feedback on Copilot code review. Take the survey.

…e unconsumed events

The unconsumed event check was firing during the async gap between
run_started consumption and the workflow function subscribing its
first step callbacks. This happened because hydrateWorkflowArguments
is async, and during its await, the EventsConsumer advanced to
step_created events that had no subscriber yet.

Fix: chain hydrateWorkflowArguments onto the promiseQueue so the
unconsumed check (which waits for the queue to drain) doesn't fire
until after the workflow arguments are hydrated and the workflow
function has been invoked.
…ise propagation

setTimeout(0) is insufficient because Node.js does not guarantee that
macrotasks fire after all cross-context (VM boundary) microtasks settle.
After promiseQueue resolves and resolve() fires in the host context,
there are multiple microtask hops through the VM boundary before the
workflow code actually calls subscribe(). A 100ms delay provides
sufficient time for this propagation while still detecting truly
orphaned events promptly.

Also update sleep.test.ts to wait 200ms for the unconsumed check.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants