Skip to content

[world-vercel] Fix run_failed event schema validation with separate resolve/lazy wire schemas#1222

Merged
TooTallNate merged 5 commits into
mainfrom
fix/run-failed-event-schema-validation
Mar 3, 2026
Merged

[world-vercel] Fix run_failed event schema validation with separate resolve/lazy wire schemas#1222
TooTallNate merged 5 commits into
mainfrom
fix/run-failed-event-schema-validation

Conversation

@TooTallNate
Copy link
Copy Markdown
Member

@TooTallNate TooTallNate commented Feb 27, 2026

Summary

  • EventResultWireSchema was using the strict WorkflowRunSchema (discriminated union) to validate the run entity in the server response. For status: 'failed', this requires error: StructuredErrorSchema — but run_failed events use remoteRefBehavior: 'lazy', so the server may return the error as a string or undefined, causing Zod validation to fail.
  • Instead of replacing the strict schema globally with the loose WorkflowRunWireBaseSchema (which would degrade type safety for all events), this PR splits the validation into two schemas selected by remoteRefBehavior:
    • EventResultResolveWireSchema — uses WorkflowRunSchema (strict discriminated union) for events where the client reads result.run (run_created, run_started, step_started). The server fully resolves refs in this mode, so type invariants always hold.
    • EventResultLazyWireSchema — uses WorkflowRunWireBaseSchema (loose) for events where the client discards the response (run_failed, run_completed, run_cancelled, etc.). deserializeError() normalizes the wire-format error field afterward.
  • Exported WorkflowRunWireBaseSchema from runs.ts so it can be imported by events.ts.
  • This follows the same pattern already used in listWorkflowRuns and getWorkflowRun in runs.ts, which select between WorkflowRunWireWithRefsSchema and WorkflowRunWireSchema based on remoteRefBehavior.

The EventResultWireSchema used the strict WorkflowRunSchema (discriminated
union) which requires error: StructuredErrorSchema for status 'failed'. When
run_failed events use remoteRefBehavior 'lazy', the server returns the error
field as a RemoteRef or undefined, causing Zod validation to fail.

Switch to WorkflowRunWireBaseSchema which accepts error as string, structured
object, or undefined, and apply deserializeError() to normalize the run entity
before returning it to consumers.

Closes #1180
Copilot AI review requested due to automatic review settings February 27, 2026 19:25
@TooTallNate TooTallNate requested a review from a team as a code owner February 27, 2026 19:25
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 27, 2026

🦋 Changeset detected

Latest commit: d59a227

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

This PR includes changesets to release 15 packages
Name Type
@workflow/world-vercel Patch
@workflow/cli Patch
@workflow/core Patch
workflow Patch
@workflow/world-testing Patch
@workflow/builders Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/web-shared 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

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Feb 27, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 27, 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 Feb 27, 2026

📊 Benchmark Results

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

workflow with no steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Nitro 0.033s (-6.8% 🟢) 1.005s (~) 0.972s 10 1.00x
💻 Local Express 0.033s (+0.9%) 1.005s (~) 0.972s 10 1.00x
🐘 Postgres Nitro 0.053s (-3.1%) 1.011s (~) 0.958s 10 1.62x
🐘 Postgres Express 0.057s (+29.7% 🔺) 1.011s (~) 0.954s 10 1.73x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 0.537s (+13.0% 🔺) 1.886s (-1.7%) 1.349s 10 1.00x
▲ Vercel Next.js (Turbopack) 0.546s (+12.4% 🔺) 1.793s (-11.7% 🟢) 1.247s 10 1.02x
▲ Vercel Express 0.549s (+17.1% 🔺) 2.067s (+10.8% 🔺) 1.518s 10 1.02x

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

workflow with 1 step

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Express 1.105s (~) 2.005s (~) 0.900s 10 1.00x
💻 Local Nitro 1.109s (~) 2.006s (~) 0.897s 10 1.00x
🐘 Postgres Express 1.136s (+2.7%) 2.013s (~) 0.877s 10 1.03x
🐘 Postgres Nitro 1.143s (~) 2.013s (~) 0.870s 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 2.099s (+6.0% 🔺) 3.408s (+9.7% 🔺) 1.308s 10 1.00x
▲ Vercel Express 2.171s (+6.1% 🔺) 3.302s (+4.2%) 1.131s 10 1.03x
▲ Vercel Next.js (Turbopack) 2.205s (+8.2% 🔺) 3.270s (~) 1.065s 10 1.05x

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

workflow with 10 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Express 10.848s (~) 11.022s (~) 0.174s 3 1.00x
💻 Local Nitro 10.867s (~) 11.022s (~) 0.156s 3 1.00x
🐘 Postgres Express 10.960s (+3.0%) 11.048s (~) 0.088s 3 1.01x
🐘 Postgres Nitro 10.966s (+0.7%) 11.042s (~) 0.076s 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 🥇 Nitro 17.038s (-1.4%) 18.114s (~) 1.075s 2 1.00x
▲ Vercel Express 17.046s (+3.3%) 17.715s (~) 0.670s 2 1.00x
▲ Vercel Next.js (Turbopack) 17.071s (~) 17.718s (-1.6%) 0.647s 2 1.00x

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

workflow with 25 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 27.401s (+0.6%) 28.067s (~) 0.666s 3 1.00x
🐘 Postgres Express 27.466s (+2.8%) 28.071s (+3.7%) 0.606s 3 1.00x
💻 Local Nitro 27.584s (~) 28.054s (~) 0.470s 3 1.01x
💻 Local Express 27.612s (~) 28.056s (~) 0.444s 3 1.01x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 44.410s (+0.5%) 45.797s (+1.5%) 1.387s 2 1.00x
▲ Vercel Express 44.739s (-0.5%) 45.635s (-0.8%) 0.897s 2 1.01x
▲ Vercel Nitro 45.654s (+0.8%) 46.892s (+1.5%) 1.238s 2 1.03x

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

workflow with 50 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 55.380s (+0.6%) 56.112s (+1.9%) 0.733s 2 1.00x
🐘 Postgres Express 55.416s (+2.4%) 56.119s (+2.8%) 0.703s 2 1.00x
💻 Local Nitro 57.573s (~) 58.106s (~) 0.533s 2 1.04x
💻 Local Express 57.704s (+0.6%) 58.103s (~) 0.399s 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 🥇 Next.js (Turbopack) 96.670s (+2.2%) 98.112s (+1.8%) 1.442s 1 1.00x
▲ Vercel Express 97.699s (+4.4%) 100.376s (+4.7%) 2.677s 1 1.01x
▲ Vercel Nitro 100.815s (+7.3% 🔺) 101.871s (+7.8% 🔺) 1.056s 1 1.04x

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

Promise.all with 10 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 1.394s (+8.4% 🔺) 2.010s (~) 0.616s 15 1.00x
🐘 Postgres Nitro 1.399s (+1.2%) 2.011s (~) 0.612s 15 1.00x
💻 Local Nitro 1.427s (+0.8%) 2.006s (~) 0.579s 15 1.02x
💻 Local Express 1.436s (+2.8%) 2.005s (~) 0.569s 15 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 🥇 Express 2.262s (-14.3% 🟢) 3.177s (-15.8% 🟢) 0.915s 10 1.00x
▲ Vercel Nitro 2.344s (+5.6% 🔺) 3.366s (+5.3% 🔺) 1.022s 9 1.04x
▲ Vercel Next.js (Turbopack) 2.404s (-33.3% 🟢) 3.147s (-31.7% 🟢) 0.742s 10 1.06x

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

Promise.all with 25 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 2.090s (+16.1% 🔺) 2.598s (+29.2% 🔺) 0.509s 12 1.00x
🐘 Postgres Nitro 2.103s (+2.4%) 2.740s (+5.5% 🔺) 0.636s 11 1.01x
💻 Local Nitro 2.679s (-2.2%) 3.007s (~) 0.328s 10 1.28x
💻 Local Express 2.686s (+3.7%) 3.007s (~) 0.321s 10 1.29x
💻 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.567s (-13.7% 🟢) 3.572s (-7.7% 🟢) 1.005s 9 1.00x
▲ Vercel Express 2.635s (-7.2% 🟢) 3.775s (-2.9%) 1.141s 8 1.03x
▲ Vercel Next.js (Turbopack) 3.165s (+15.0% 🔺) 4.192s (+11.6% 🔺) 1.026s 8 1.23x

🔍 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 🥇 Express 3.647s (+35.3% 🔺) 4.452s (+21.0% 🔺) 0.805s 7 1.00x
🐘 Postgres Nitro 4.023s (-4.3%) 4.879s (-2.8%) 0.856s 7 1.10x
💻 Local Nitro 7.824s (-1.6%) 8.020s (-3.0%) 0.196s 4 2.15x
💻 Local Express 8.236s (+12.7% 🔺) 8.777s (+9.5% 🔺) 0.541s 4 2.26x
💻 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.071s (-6.0% 🟢) 3.975s (-3.9%) 0.903s 8 1.00x
▲ Vercel Express 3.088s (-14.4% 🟢) 4.428s (-5.9% 🟢) 1.339s 7 1.01x
▲ Vercel Nitro 3.490s (~) 4.637s (+4.8%) 1.147s 7 1.14x

🔍 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.364s (-1.9%) 2.011s (~) 0.647s 15 1.00x
🐘 Postgres Express 1.387s (+9.4% 🔺) 2.012s (~) 0.625s 15 1.02x
💻 Local Nitro 1.435s (-2.1%) 2.005s (~) 0.570s 15 1.05x
💻 Local Express 1.465s (+1.9%) 2.005s (~) 0.540s 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.208s (+3.0%) 3.464s (+9.5% 🔺) 1.255s 9 1.00x
▲ Vercel Next.js (Turbopack) 2.245s (-5.1% 🟢) 3.487s (-6.9% 🟢) 1.242s 9 1.02x
▲ Vercel Express 2.511s (+14.4% 🔺) 3.594s (+4.3%) 1.084s 9 1.14x

🔍 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 🥇 Express 1.995s (+17.3% 🔺) 2.515s (+21.0% 🔺) 0.520s 12 1.00x
🐘 Postgres Nitro 2.043s (-3.4%) 2.741s (+5.6% 🔺) 0.699s 11 1.02x
💻 Local Nitro 2.808s (-1.0%) 3.008s (-3.2%) 0.200s 10 1.41x
💻 Local Express 2.830s (+4.9%) 3.007s (~) 0.177s 10 1.42x
💻 Local Next.js (Turbopack) ⚠️ missing - - - -
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 2.537s (-7.1% 🟢) 3.565s (-0.8%) 1.028s 9 1.00x
▲ Vercel Next.js (Turbopack) 2.895s (-11.0% 🟢) 3.628s (-11.4% 🟢) 0.733s 9 1.14x
▲ Vercel Express 2.897s (-0.6%) 4.019s (~) 1.121s 8 1.14x

🔍 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.260s (-9.5% 🟢) 4.024s (-6.6% 🟢) 0.764s 8 1.00x
🐘 Postgres Express 3.837s (+31.5% 🔺) 4.449s (+18.2% 🔺) 0.612s 7 1.18x
💻 Local Nitro 8.235s (-3.9%) 9.022s (~) 0.787s 4 2.53x
💻 Local Express 8.478s (+8.6% 🔺) 9.022s (+12.5% 🔺) 0.544s 4 2.60x
💻 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.843s (+0.7%) 3.852s (-7.1% 🟢) 1.009s 8 1.00x
▲ Vercel Express 3.110s (-1.6%) 4.262s (+3.2%) 1.152s 8 1.09x
▲ Vercel Next.js (Turbopack) 3.465s (+11.5% 🔺) 4.598s (+16.4% 🔺) 1.133s 8 1.22x

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

Stream Benchmarks (includes TTFB metrics)
workflow with stream

💻 Local Development

World Framework Workflow Time TTFB Slurp Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Nitro 0.175s (-5.1% 🟢) 1.002s (~) 0.012s (+4.3%) 1.018s (~) 0.843s 10 1.00x
💻 Local Express 0.176s (+1.4%) 1.002s (~) 0.012s (+5.3% 🔺) 1.017s (~) 0.841s 10 1.01x
🐘 Postgres Express 0.212s (+54.9% 🔺) 0.994s (~) 0.001s (+20.0% 🔺) 1.012s (~) 0.799s 10 1.21x
🐘 Postgres Nitro 0.213s (+6.5% 🔺) 0.993s (~) 0.001s (-25.0% 🟢) 1.012s (~) 0.798s 10 1.22x
💻 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.800s (+16.8% 🔺) 2.357s (+11.7% 🔺) 0.201s (+70.0% 🔺) 3.020s (+14.2% 🔺) 1.220s 10 1.00x
▲ Vercel Express 1.822s (+15.6% 🔺) 2.445s (+19.3% 🔺) 0.172s (+7.3% 🔺) 3.061s (+15.8% 🔺) 1.240s 10 1.01x
▲ Vercel Next.js (Turbopack) 1.935s (+19.2% 🔺) 2.808s (+17.9% 🔺) 0.170s (-29.6% 🟢) 3.488s (+12.5% 🔺) 1.553s 10 1.08x

🔍 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 Express 7/12
▲ Vercel Nitro 8/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 6/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 updates the @workflow/world-vercel client to avoid Zod validation failures when creating run_failed events in remoteRefBehavior: 'lazy' mode, by loosening the wire-schema for the returned run and normalizing the wire error format before returning results.

Changes:

  • Exported WorkflowRunWireBaseSchema from runs.ts so it can be reused elsewhere.
  • Updated events.create result validation to use WorkflowRunWireBaseSchema for the optional run field and applied deserializeError() before returning run.
  • Added a changeset to publish a patch release documenting the fix.

Reviewed changes

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

File Description
packages/world-vercel/src/runs.ts Exports WorkflowRunWireBaseSchema for reuse by event result parsing.
packages/world-vercel/src/events.ts Uses the wire-base run schema for event-create responses and normalizes run errors via deserializeError().
.changeset/fix-run-failed-schema.md Declares a patch release and documents the validation fix.

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

Comment thread packages/world-vercel/src/events.ts Outdated
Comment thread packages/world-vercel/src/events.ts
Comment thread packages/world-vercel/src/events.ts
…lazy mode

Split EventResultWireSchema into two variants based on remoteRefBehavior:
- EventResultResolveWireSchema uses WorkflowRunSchema (discriminated union)
  for events where the client reads result.run (run_created, run_started,
  step_started), preserving type safety.
- EventResultLazyWireSchema uses WorkflowRunWireBaseSchema for events where
  the client discards the response, allowing error to be a string or
  undefined in lazy ref mode.
@TooTallNate TooTallNate changed the title [world-vercel] Fix run_failed event schema validation failure in lazy ref mode [world-vercel] Fix run_failed event schema validation with separate resolve/lazy wire schemas Mar 3, 2026
@karthikscale3
Copy link
Copy Markdown
Contributor

Here's my analysis of PR #1222.


Summary

This PR fixes a Zod validation failure when the server returns run_failed events in lazy ref mode, where the error field may be a string or undefined instead of the structured object that the strict WorkflowRunSchema discriminated union demands.

Regression Analysis: No regressions expected

The resolve path is behavior-identical to the old code. For events in eventsNeedingResolve (run_created, run_started, step_started), the new EventResultResolveWireSchema uses the same WorkflowRunSchema.optional() validation as the old unified EventResultWireSchema. The return shape is unchanged — wireResult.run is passed through directly without deserializeError(), which is correct because the strict schema already guarantees the error is a StructuredError object (not a string).

The lazy path fixes the bug without side effects. I verified all callers of events.create() in packages/core/src/:

Event type Ref mode Caller reads result.run?
run_created resolve Yes — reads result.run.runId in start.ts:140
run_started resolve Yes — uses result.run as workflowRun in runtime.ts:150
step_started resolve Yes — reads result.step in step-handler.ts:129
run_failed lazy No — result discarded (runtime.ts:397)
run_completed lazy No — result discarded (runtime.ts:269)
run_cancelled lazy No — result discarded (runtime/run.ts:86)
step_completed lazy No — result discarded (step-handler.ts:406)
step_failed lazy No — result discarded (multiple sites)
step_retrying lazy No — result discarded (step-handler.ts:644)

Every lazy-path event discards the run field, so the looser schema + deserializeError() normalization doesn't change any consumed data. Even if a caller did read result.run, they'd get a properly normalized error (better than the current crash from Zod validation failure).

The pattern is already established. listWorkflowRuns and getWorkflowRun in runs.ts already select between WorkflowRunWireWithRefsSchema (lazy) and WorkflowRunWireSchema (resolve) based on remoteRefBehavior. This PR applies the same approach to createWorkflowRunEvent.

Security Analysis: No issues

  1. Schema relaxation is scoped and intentional. The loose WorkflowRunWireBaseSchema is only used for the lazy path where clients discard entity data. The strict discriminated union remains for the resolve path where clients actually consume result.run.

  2. deserializeError sanitizes properly. It validates through StructuredErrorSchema.safeParse() and only extracts message, stack, code — no arbitrary fields pass through. If the error is null/undefined, it returns the object as-is. If it's a string, it attempts JSON parse into a structured error. Unknown formats fall through safely.

  3. No new input vectors. remoteRefBehavior is determined entirely by the hardcoded eventsNeedingResolve set — it's not user-controlled.

  4. Minor note on the export. WorkflowRunWireBaseSchema is now export const instead of const. This widens the public surface of @workflow/world-vercel, but the schema is just a Zod shape validator with no sensitive logic. Downstream consumers could import it, but there's no harm in that.

Verdict

Clean and safe. The fix is well-scoped, follows established patterns in the same codebase, and only relaxes validation where the strict schema was provably wrong (lazy mode can't guarantee discriminated union invariants). No regressions or security concerns.

@TooTallNate TooTallNate merged commit 2b1c2bd into main Mar 3, 2026
164 of 167 checks passed
@TooTallNate TooTallNate deleted the fix/run-failed-event-schema-validation branch March 3, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants