Skip to content

Wire AES-GCM encryption into serialization layer#1251

Merged
TooTallNate merged 29 commits intomainfrom
nate/wire-encryption
Mar 4, 2026
Merged

Wire AES-GCM encryption into serialization layer#1251
TooTallNate merged 29 commits intomainfrom
nate/wire-encryption

Conversation

@TooTallNate
Copy link
Copy Markdown
Member

Summary

Wires AES-GCM encryption into the serialization layer, building on the async deserialization ordering fix from #1246.

Encryption

  • maybeEncrypt/maybeDecrypt in serialization.ts with encr 4-byte format prefix
  • All 8 dehydrate/hydrate functions accept optional key: CryptoKey | undefined
  • Stream encryption/decryption with cached CryptoKey per stream instance
  • 32 encryption unit tests (primitives, maybeEncrypt/maybeDecrypt, isEncrypted, complex type round-trips)

Key management

  • Browser-compatible AES-256-GCM encryption module using Web Crypto API
  • HKDF key derivation moved server-side: API returns per-run derived key
  • getEncryptionKeyForRun overloaded to accept context for start(), fetch WorkflowRun in resume-hook
  • CryptoKey cached and passed through workflow orchestrator context

Continues from #957 (closed due to base branch deletion), with the EventsConsumer async ordering fix now landed via #1246.

@TooTallNate TooTallNate requested a review from a team as a code owner March 3, 2026 22:48
Copilot AI review requested due to automatic review settings March 3, 2026 22:48
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Mar 3, 2026

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 3, 2026

🦋 Changeset detected

Latest commit: bc01397

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 3, 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 (-1.5%) 1.006s (~) 0.973s 10 1.00x
💻 Local Express 0.035s (+28.9% 🔺) 1.006s (~) 0.971s 10 1.05x
💻 Local Next.js (Turbopack) 0.043s 1.005s 0.962s 10 1.31x
🌐 Redis Next.js (Turbopack) 0.045s 1.005s 0.960s 10 1.38x
🐘 Postgres Express 0.050s (-12.0% 🟢) 1.012s (~) 0.962s 10 1.52x
🐘 Postgres Nitro 0.056s (-5.0%) 1.011s (~) 0.955s 10 1.68x
🌐 MongoDB Next.js (Turbopack) 0.085s 1.009s 0.924s 10 2.58x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 0.391s (-21.2% 🟢) 1.875s (-1.0%) 1.484s 10 1.00x
▲ Vercel Express 0.526s (-25.8% 🟢) 2.106s (+5.5% 🔺) 1.580s 10 1.34x
▲ Vercel Next.js (Turbopack) 0.667s (+13.9% 🔺) 2.223s (+17.5% 🔺) 1.556s 10 1.71x

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

workflow with 1 step

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Next.js (Turbopack) 1.095s 2.006s 0.911s 10 1.00x
💻 Local Nitro 1.101s (~) 2.005s (~) 0.904s 10 1.01x
🌐 Redis Next.js (Turbopack) 1.101s 2.007s 0.906s 10 1.01x
💻 Local Express 1.106s (+3.1%) 2.005s (~) 0.900s 10 1.01x
🐘 Postgres Express 1.126s (-0.6%) 2.012s (~) 0.887s 10 1.03x
🐘 Postgres Nitro 1.133s (~) 2.013s (~) 0.880s 10 1.03x
🌐 MongoDB Next.js (Turbopack) 1.273s 2.009s 0.736s 10 1.16x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 2.015s (-4.9%) 2.963s (-4.1%) 0.947s 10 1.00x
▲ Vercel Express 2.063s (+3.2%) 3.483s (+12.4% 🔺) 1.420s 10 1.02x
▲ Vercel Next.js (Turbopack) 2.168s (+8.0% 🔺) 3.558s (+24.4% 🔺) 1.390s 10 1.08x

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

workflow with 10 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 10.652s 11.023s 0.371s 3 1.00x
💻 Local Next.js (Turbopack) 10.717s 11.023s 0.306s 3 1.01x
💻 Local Nitro 10.774s (~) 11.023s (~) 0.249s 3 1.01x
💻 Local Express 10.787s (+2.4%) 11.023s (~) 0.236s 3 1.01x
🐘 Postgres Express 10.831s (-0.8%) 11.043s (~) 0.211s 3 1.02x
🐘 Postgres Nitro 10.856s (~) 11.046s (~) 0.190s 3 1.02x
🌐 MongoDB Next.js (Turbopack) 12.237s 13.020s 0.782s 3 1.15x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 17.870s (+1.2%) 19.891s (+8.3% 🔺) 2.020s 2 1.00x
▲ Vercel Express 18.025s (~) 19.732s (+3.3%) 1.707s 2 1.01x
▲ Vercel Nitro 19.976s (+17.2% 🔺) 21.273s (+19.0% 🔺) 1.297s 2 1.12x

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

workflow with 25 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 26.550s 27.051s 0.501s 3 1.00x
💻 Local Next.js (Turbopack) 26.898s 27.056s 0.158s 3 1.01x
🐘 Postgres Express 26.960s (~) 27.064s (-1.2%) 0.104s 3 1.02x
🐘 Postgres Nitro 27.012s (~) 27.065s (-1.2%) 0.052s 3 1.02x
💻 Local Express 27.224s (+2.6%) 28.053s (+3.7%) 0.829s 3 1.03x
💻 Local Nitro 27.227s (~) 28.054s (~) 0.828s 3 1.03x
🌐 MongoDB Next.js (Turbopack) 30.134s 30.547s 0.412s 2 1.14x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 43.395s (-4.9%) 45.072s (-4.0%) 1.677s 2 1.00x
▲ Vercel Nitro 45.351s (-0.6%) 46.359s (~) 1.008s 2 1.05x
▲ Vercel Next.js (Turbopack) 45.883s (+4.2%) 47.476s (+6.1% 🔺) 1.593s 2 1.06x

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

workflow with 50 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 53.066s 53.100s 0.034s 2 1.00x
🐘 Postgres Nitro 53.782s (~) 54.101s (~) 0.319s 2 1.01x
🐘 Postgres Express 53.833s (~) 54.103s (~) 0.270s 2 1.01x
💻 Local Next.js (Turbopack) 55.617s 56.105s 0.488s 2 1.05x
💻 Local Nitro 56.054s (~) 56.102s (~) 0.048s 2 1.06x
💻 Local Express 56.136s (+3.0%) 57.106s (+3.6%) 0.970s 2 1.06x
🌐 MongoDB Next.js (Turbopack) 60.167s 60.579s 0.412s 2 1.13x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 100.363s (-2.2%) 102.448s (-0.9%) 2.085s 1 1.00x
▲ Vercel Express 100.931s (-6.4% 🟢) 102.587s (-6.1% 🟢) 1.656s 1 1.01x
▲ Vercel Nitro 101.566s (+1.0%) 103.071s (+1.6%) 1.505s 1 1.01x

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

Promise.all with 10 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 1.276s 2.006s 0.731s 15 1.00x
🐘 Postgres Nitro 1.368s (~) 2.011s (~) 0.644s 15 1.07x
🐘 Postgres Express 1.374s (+1.8%) 2.012s (~) 0.638s 15 1.08x
💻 Local Nitro 1.422s (+0.7%) 2.005s (~) 0.582s 15 1.12x
💻 Local Express 1.429s (+4.4%) 2.006s (~) 0.577s 15 1.12x
💻 Local Next.js (Turbopack) 1.430s 2.006s 0.575s 15 1.12x
🌐 MongoDB Next.js (Turbopack) 2.138s 3.009s 0.871s 10 1.68x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 2.743s (~) 3.920s (+2.8%) 1.176s 8 1.00x
▲ Vercel Next.js (Turbopack) 2.868s (+9.4% 🔺) 3.951s (+15.7% 🔺) 1.084s 8 1.05x
▲ Vercel Nitro 2.939s (+21.0% 🔺) 3.868s (+12.3% 🔺) 0.929s 8 1.07x

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

Promise.all with 25 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 2.043s (-5.2% 🟢) 2.682s (-5.3% 🟢) 0.640s 12 1.00x
🐘 Postgres Nitro 2.062s (+5.0% 🔺) 2.597s (~) 0.535s 12 1.01x
🌐 Redis Next.js (Turbopack) 2.500s 3.008s 0.508s 10 1.22x
💻 Local Nitro 2.567s (~) 3.007s (~) 0.441s 10 1.26x
💻 Local Next.js (Turbopack) 2.658s 3.008s 0.350s 10 1.30x
💻 Local Express 2.667s (+15.4% 🔺) 3.007s (~) 0.340s 10 1.31x
🌐 MongoDB Next.js (Turbopack) 4.649s 5.176s 0.527s 6 2.28x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 2.498s (-4.8%) 3.778s (+5.5% 🔺) 1.281s 8 1.00x
▲ Vercel Nitro 2.858s (-2.7%) 4.154s (+11.7% 🔺) 1.296s 8 1.14x
▲ Vercel Express 3.370s (+4.8%) 4.423s (+6.7% 🔺) 1.054s 8 1.35x

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

Promise.all with 50 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Nitro 3.805s (-7.9% 🟢) 4.459s (-11.3% 🟢) 0.654s 7 1.00x
🐘 Postgres Express 4.055s (+12.3% 🔺) 4.879s (+13.2% 🔺) 0.824s 7 1.07x
🌐 Redis Next.js (Turbopack) 4.267s 5.011s 0.744s 6 1.12x
💻 Local Next.js (Turbopack) 7.268s 7.765s 0.497s 4 1.91x
💻 Local Nitro 7.380s (+1.1%) 8.021s (~) 0.642s 4 1.94x
💻 Local Express 7.691s (+18.1% 🔺) 8.018s (+14.3% 🔺) 0.327s 4 2.02x
🌐 MongoDB Next.js (Turbopack) 9.891s 10.351s 0.460s 3 2.60x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 2.974s (-17.6% 🟢) 4.394s (-4.7%) 1.420s 7 1.00x
▲ Vercel Express 3.661s (-1.6%) 5.006s (+6.5% 🔺) 1.345s 6 1.23x
▲ Vercel Next.js (Turbopack) 3.896s (+21.0% 🔺) 5.025s (+27.8% 🔺) 1.129s 6 1.31x

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

Promise.race with 10 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 1.230s 2.006s 0.777s 15 1.00x
🐘 Postgres Express 1.397s (+1.2%) 2.011s (~) 0.614s 15 1.14x
🐘 Postgres Nitro 1.399s (-0.9%) 2.012s (~) 0.613s 15 1.14x
💻 Local Next.js (Turbopack) 1.418s 2.006s 0.588s 15 1.15x
💻 Local Nitro 1.421s (+1.4%) 2.005s (~) 0.584s 15 1.16x
💻 Local Express 1.439s (+4.5%) 2.006s (~) 0.568s 15 1.17x
🌐 MongoDB Next.js (Turbopack) 2.141s 3.009s 0.868s 10 1.74x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 2.224s (+5.8% 🔺) 3.126s (-1.3%) 0.901s 10 1.00x
▲ Vercel Express 2.251s (+6.9% 🔺) 3.356s (+4.0%) 1.105s 9 1.01x
▲ Vercel Next.js (Turbopack) 2.397s (+9.9% 🔺) 3.564s (+25.7% 🔺) 1.167s 9 1.08x

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

Promise.race with 25 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 1.962s (-5.6% 🟢) 2.516s (-8.2% 🟢) 0.554s 12 1.00x
🐘 Postgres Nitro 2.116s (-2.0%) 2.741s (~) 0.625s 11 1.08x
🌐 Redis Next.js (Turbopack) 2.515s 3.008s 0.494s 10 1.28x
💻 Local Next.js (Turbopack) 2.719s 3.008s 0.289s 10 1.39x
💻 Local Express 2.793s (+11.7% 🔺) 3.009s (~) 0.217s 10 1.42x
💻 Local Nitro 2.818s (+6.5% 🔺) 3.109s (+3.4%) 0.290s 10 1.44x
🌐 MongoDB Next.js (Turbopack) 4.791s 5.176s 0.385s 6 2.44x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Express 2.464s (-1.8%) 3.449s (~) 0.985s 9 1.00x
▲ Vercel Nitro 2.664s (+10.9% 🔺) 3.344s (+1.5%) 0.680s 9 1.08x
▲ Vercel Next.js (Turbopack) 2.857s (+19.4% 🔺) 3.991s (+34.0% 🔺) 1.135s 8 1.16x

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

Promise.race with 50 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🐘 Postgres 🥇 Express 3.602s (-3.8%) 4.403s (-4.3%) 0.801s 8 1.00x
🐘 Postgres Nitro 4.072s (+22.3% 🔺) 4.741s (+17.9% 🔺) 0.669s 7 1.13x
🌐 Redis Next.js (Turbopack) 4.252s 5.011s 0.759s 6 1.18x
💻 Local Next.js (Turbopack) 7.905s 8.518s 0.613s 4 2.19x
💻 Local Express 8.382s (+19.1% 🔺) 9.021s (+16.2% 🔺) 0.639s 4 2.33x
💻 Local Nitro 8.501s (+6.6% 🔺) 9.020s (+9.1% 🔺) 0.520s 4 2.36x
🌐 MongoDB Next.js (Turbopack) 9.919s 10.350s 0.431s 3 2.75x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 3.047s (-10.6% 🟢) 4.219s (-2.0%) 1.172s 8 1.00x
▲ Vercel Express 3.232s (-6.1% 🟢) 4.593s (+4.8%) 1.361s 7 1.06x
▲ Vercel Next.js (Turbopack) 3.474s (-7.3% 🟢) 4.969s (+6.3% 🔺) 1.495s 7 1.14x

🔍 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 🥇 Next.js (Turbopack) 0.143s 1.001s 0.011s 1.017s 0.874s 10 1.00x
🌐 Redis Next.js (Turbopack) 0.145s 1.000s 0.002s 1.008s 0.862s 10 1.02x
💻 Local Nitro 0.173s (+2.8%) 1.002s (~) 0.011s (-3.4%) 1.017s (~) 0.844s 10 1.21x
💻 Local Express 0.173s (+59.2% 🔺) 1.003s (~) 0.011s (+22.3% 🔺) 1.017s (~) 0.844s 10 1.21x
🐘 Postgres Nitro 0.189s (-6.7% 🟢) 0.994s (~) 0.002s (-11.1% 🟢) 1.013s (~) 0.823s 10 1.32x
🐘 Postgres Express 0.192s (-5.3% 🟢) 0.995s (~) 0.002s (-11.1% 🟢) 1.013s (~) 0.821s 10 1.34x
🌐 MongoDB Next.js (Turbopack) 0.488s 0.951s 0.001s 1.009s 0.521s 10 3.41x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - - -

▲ Production (Vercel)

World Framework Workflow Time TTFB Slurp Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 1.611s (-9.5% 🟢) 2.375s (-6.0% 🟢) 0.171s (+9.6% 🔺) 3.010s (-2.3%) 1.399s 10 1.00x
▲ Vercel Nitro 1.642s (+5.2% 🔺) 2.633s (+16.4% 🔺) 0.169s (+41.7% 🔺) 3.186s (+12.4% 🔺) 1.544s 10 1.02x
▲ Vercel Express 1.794s (+8.2% 🔺) 2.759s (+4.8%) 0.131s (-22.3% 🟢) 63.378s (+1856.6% 🔺) 61.584s 10 1.11x

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

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World 🥇 Fastest Framework Wins
💻 Local Next.js (Turbopack) 9/12
🐘 Postgres Express 8/12
▲ Vercel Nitro 5/12
Fastest World by Framework

Winner determined by most benchmark wins

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 3, 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 116 49 15 180
✅ 📋 Other 138 0 27 165
Total 2572 49 364 2985

❌ Failed Tests

🌍 Community Worlds (49 failed)

mongodb (1 failed):

  • webhookWorkflow

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 51 1 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

The rebase incorrectly picked up older versions of these files from
early encryption branch commits. The main versions are correct and
up-to-date.
- Remove Vercel-specific error message from maybeDecrypt (core should
  not reference VERCEL_DEPLOYMENT_KEY)
- Move stream encryption/decryption from transport layer
  (WorkflowServerReadableStream/WritableStream) to framing layer
  (getSerializeStream/getDeserializeStream). Frame length headers stay
  in the clear so frame boundaries are always parseable regardless of
  transport chunking; encryption wraps the frame payload.
- Remove explicit Promise<unknown> return types from all 4 hydrate
  functions. On main these had inferred types (any from devalue),
  so callers didn't need casts. The encryption branch added explicit
  annotations that broke this.
- Revert unnecessary type casts in run.ts, step-handler.ts, hook.ts
  that were only needed due to the explicit Promise<unknown> annotations
- Revert closureVars type from unknown back to Record<string, any>
  in context-storage.ts to match the contract with getClosureVars
- Fix hydrateWorkflowArguments JSDoc for unused _runId parameter
…gacy comments

- Remove unused _runId parameter from WorkflowServerReadableStream
  constructor and all 4 call sites
- Deduplicate processFrames decryption: decrypt first and reassign
  format/payload, then fall through to single deserialization path
- Add comments on all legacy non-Uint8Array branches explaining when
  this happens (specVersion 1 runs stored data as plain JSON arrays)
- Fix duplicate code block in hydrateStepReturnValue
Thread the encryption key through the entire stream serialization chain
so that ReadableStream and WritableStream values are encrypted/decrypted
at the framing level.

- Add optional cryptoKey param to getExternalReducers, getStepReducers,
  getExternalRevivers, getStepRevivers
- Pass cryptoKey to getSerializeStream/getDeserializeStream at all 8
  internal call sites within reducers/revivers
- Thread key from dehydrate/hydrate functions into their reducers/revivers
- Cache encryption key in Run class (resolved once via getEncryptionKey(),
  reused for returnValue, getReadable(), etc.)
- Make Run#getReadable() async to resolve the cached key before creating
  the deserialize stream
- Add encryptionKey to step context storage so getWritable() can access
  it during step execution
… add stream encryption tests

Change cryptoKey parameter from optional (cryptoKey?) to required-but-
nullable (cryptoKey: CryptoKey | undefined) on all 6 functions:
- getSerializeStream, getDeserializeStream
- getExternalReducers, getStepReducers
- getExternalRevivers, getStepRevivers

This ensures every call site must explicitly pass the key or undefined,
making it impossible to accidentally omit it and silently skip encryption.

Add 7 stream encryption round-trip tests:
- Encrypted frames have 'encr' prefix inside length header
- Full round-trip: encrypt serialize -> decrypt deserialize
- Concatenated encrypted frames (transport coalescing)
- Split encrypted frames (transport splitting)
- Error when encrypted data encountered without key
- No encryption when key is undefined
- Large payload round-trip

Full audit confirms all encryption key threading is complete:
- All 8 dehydrate/hydrate functions pass key to reducers/revivers
- All stream serialize/deserialize call sites pass key
- Run class caches key for reuse across returnValue and getReadable()
- Step context storage carries key for getWritable()
…reams

- Revert Run#getReadable() to synchronous (non-breaking API).
  The encryption key is passed as a Promise through the chain and
  resolved lazily inside the first async transform() call.
- Add EncryptionKeyParam type alias that accepts CryptoKey, undefined,
  or Promise<CryptoKey | undefined>. Used by getSerializeStream,
  getDeserializeStream, and all reducer/reviver functions.
- Key promises are resolved once on first use via a keyState cache
  object inside each stream's transform closure.
- Fix CLI showStream to resolve encryption key from world when runId
  is provided via --run flag, instead of passing undefined.
- Remove incorrect CLI warning that --run is not supported for streams
  (it is now needed for encrypted stream decryption).
Copy link
Copy Markdown
Member

@VaguelySerious VaguelySerious left a comment

Choose a reason for hiding this comment

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

Some issues claude flagged:

  1. Pre-existing: workflow.test.ts lines 3360, 3434, 3510, 3567 These 4 calls are dehydrateWorkflowArguments([], ops) — passing ops (a Promise[]) as the runId parameter and omitting key. This pre-dates this PR (the key param already existed on the base branch), but it's worth noting these tests are broken and should be fixed in this PR or a follow-up.
  2. maybeDecrypt throws WorkflowRuntimeError when encrypted data has no key (serialization.ts:1527). This is the correct behavior, but the throw is unguarded in all hydrate callers. For example, in Run.pollReturnValue() (run.ts:206), if getEncryptionKey() resolves to undefined but the stored output was encrypted, hydrateWorkflowReturnValue will throw. This surfaces as a rejected promise on run.returnValue with no recovery path. The error message is good, but callers should be aware this can happen during a production key-rotation or misconfiguration scenario.
  3. getDeserializeStream — controller.error() on encrypted-data-without-key (serialization.ts:346-355). When the deserialize stream encounters an encrypted frame but has no key, it calls controller.error() and returns. The writable side is not explicitly aborted — writers may hang or silently fail depending on timing. This is a minor edge case since it only happens in a misconfiguration scenario, but a writer.abort() or controller.terminate() would be more robust.
  4. decodeFormatPrefix throws plain Error on unknown format (serialization.ts:181). If a future format prefix (e.g., "cbor") is encountered by older code, decodeFormatPrefix throws Error: Unknown serialization format: "xxxx". This is a plain Error, not a WorkflowRuntimeError, making it harder to programmatically distinguish from other errors. All hydrate functions expose this throw path. Consider using WorkflowRuntimeError for consistency.
  5. Key-fetch rejection timing in streams. If the cryptoKey promise (passed as EncryptionKeyParam) rejects before the first stream frame arrives, the rejection is unobserved until data actually flows. This means a key-fetch failure (e.g., network error fetching the derived key) won't surface until the stream gets its first chunk. Not a bug, but worth documenting.

Comment thread packages/cli/src/lib/inspect/output.ts
- Fix 4 broken dehydrateWorkflowArguments calls in workflow.test.ts
  that were passing ops as runId (missing runId and key params)
- Use WorkflowRuntimeError instead of plain Error in decodeFormatPrefix
  for unknown serialization formats, for consistency and programmatic
  error handling
- Document maybeDecrypt throw behavior: callers should be aware this
  surfaces as a rejected promise during key rotation/misconfiguration
- Document key-fetch rejection timing in streams: promise rejection
  won't surface until the first chunk is processed
@TooTallNate
Copy link
Copy Markdown
Member Author

Addressed all 5 issues from the review in bc01397:

  1. Fixed: 4 broken dehydrateWorkflowArguments calls in workflow.test.ts — were passing ops as runId. Now correctly pass ([], workflowRunId, noEncryptionKey, ops).

  2. Documented: maybeDecrypt throw behavior. Added JSDoc noting that callers should be aware this surfaces as a rejected promise during key rotation or misconfiguration.

  3. Acknowledged: controller.error() without explicit writer abort in getDeserializeStream. This is a minor edge case in misconfiguration — the writable side will eventually error when it tries to enqueue after the readable is errored. Not changing behavior for now but noted.

  4. Fixed: decodeFormatPrefix now throws WorkflowRuntimeError instead of plain Error for unknown formats, consistent with all other error paths.

  5. Documented: Key-fetch rejection timing in streams. Added comment noting the promise rejection won't surface until the first chunk is processed.

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