') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); [codex] Handle stream write failures without unhandled rejections by pranaygp · Pull Request #2142 · vercel/workflow · GitHub
Skip to content

[codex] Handle stream write failures without unhandled rejections - #2142

Merged
pranaygp merged 1 commit into
mainfrom
pranaygp/codex/stream-write-failure-handling
May 28, 2026
Merged

[codex] Handle stream write failures without unhandled rejections#2142
pranaygp merged 1 commit into
mainfrom
pranaygp/codex/stream-write-failure-handling

Conversation

@pranaygp

Copy link
Copy Markdown
Contributor

Summary

  • observe flushable stream-state rejections immediately so failed writes are still propagated through runtime operations without first surfacing as unhandledRejection
  • include the stream PUT endpoint and safe Vercel response correlation headers (x-vercel-id, x-vercel-error) in write/close failure errors while preserving the response body
  • add patch changesets for @workflow/core and @workflow/world-vercel

Root cause

A streaming step can fail a server write while user code is still running. flushablePipe() rejects state.promise, but the step runtime only waits on its collected operation promises after the step body returns. During that gap Node can classify the rejection as unhandled, allowing a transient stream failure to terminate the invocation instead of being handled through the runtime error path.

This PR attaches an immediate no-op rejection observer to the existing promise while leaving that original rejected promise in place for the runtime to await and propagate normally.

Retry behavior

This intentionally does not add automatic retries for failed stream writes. Writes are not currently idempotent, and a response failure after server acceptance cannot be distinguished from a failed write; blind retries can duplicate stream chunks.

Validation

  • pnpm exec biome check --write packages/core/src/flushable-stream.ts packages/core/src/flushable-stream.test.ts packages/world-vercel/src/streamer.ts packages/world-vercel/src/streamer.test.ts
  • pnpm --filter @workflow/core... build
  • WORKFLOW_TARGET_WORLD=local pnpm --filter @workflow/core exec vitest run src (1,034 tests passed)
  • pnpm --filter @workflow/world-vercel exec vitest run src (110 tests passed)
  • pnpm changeset status --since=origin-https/main
  • git diff --check

@vercel

vercelBot commented May 28, 2026

Copy link
Copy Markdown
Contributor

@changeset-bot

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 107df58

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

This PR includes changesets to release 17 packages
NameType
@workflow/corePatch
@workflow/world-vercelPatch
@workflow/buildersPatch
@workflow/cliPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/vitestPatch
@workflow/web-sharedPatch
@workflow/webPatch
workflowPatch
@workflow/world-testingPatch
@workflow/astroPatch
@workflow/nestPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
@workflow/vitePatch
@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 May 28, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production125502191474
✅ 💻 Local Development165702191876
✅ 📦 Local Production165702191876
✅ 🐘 Local Postgres165702191876
✅ 🪟 Windows13400134
✅ 📋 Other7620176938
Total7122010528174

Details by Category

✅ ▲ Vercel Production
AppPassedFailedSkipped
✅ astro108026
✅ example108026
✅ express108026
✅ fastify108026
✅ hono108026
✅ nextjs-turbopack13202
✅ nextjs-webpack13202
✅ nitro108026
✅ nuxt108026
✅ sveltekit12707
✅ vite108026
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable109025
✅ express-stable109025
✅ fastify-stable109025
✅ hono-stable109025
✅ nextjs-turbopack-canary115019
✅ nextjs-turbopack-stable-lazy-discovery-disabled13400
✅ nextjs-turbopack-stable-lazy-discovery-enabled13400
✅ nextjs-webpack-canary115019
✅ nextjs-webpack-stable-lazy-discovery-disabled13400
✅ nextjs-webpack-stable-lazy-discovery-enabled13400
✅ nitro-stable109025
✅ nuxt-stable109025
✅ sveltekit-stable12806
✅ vite-stable109025
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable109025
✅ express-stable109025
✅ fastify-stable109025
✅ hono-stable109025
✅ nextjs-turbopack-canary115019
✅ nextjs-turbopack-stable-lazy-discovery-disabled13400
✅ nextjs-turbopack-stable-lazy-discovery-enabled13400
✅ nextjs-webpack-canary115019
✅ nextjs-webpack-stable-lazy-discovery-disabled13400
✅ nextjs-webpack-stable-lazy-discovery-enabled13400
✅ nitro-stable109025
✅ nuxt-stable109025
✅ sveltekit-stable12806
✅ vite-stable109025
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable109025
✅ express-stable109025
✅ fastify-stable109025
✅ hono-stable109025
✅ nextjs-turbopack-canary115019
✅ nextjs-turbopack-stable-lazy-discovery-disabled13400
✅ nextjs-turbopack-stable-lazy-discovery-enabled13400
✅ nextjs-webpack-canary115019
✅ nextjs-webpack-stable-lazy-discovery-disabled13400
✅ nextjs-webpack-stable-lazy-discovery-enabled13400
✅ nitro-stable109025
✅ nuxt-stable109025
✅ sveltekit-stable12806
✅ vite-stable109025
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack13400
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable109025
✅ e2e-local-dev-tanstack-start-109025
✅ e2e-local-postgres-nest-stable109025
✅ e2e-local-postgres-tanstack-start-109025
✅ e2e-local-prod-nest-stable109025
✅ e2e-local-prod-tanstack-start-109025
✅ e2e-vercel-prod-tanstack-start108026

📋 View full workflow run

@github-actions

github-actionsBot commented May 28, 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.042s (-3.7%)1.005s (~)0.963s101.00x
💻 LocalExpress0.043s (-1.8%)1.006s (~)0.962s101.05x
💻 LocalNext.js (Turbopack)0.054s1.007s0.953s101.31x
🐘 PostgresExpress0.064s (+10.3% 🔺)1.012s (~)0.948s101.54x
🐘 PostgresNitro0.065s (-31.6% 🟢)1.012s (-3.0%)0.946s101.57x
🐘 PostgresNext.js (Turbopack)0.068s1.012s0.944s101.63x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro0.327s (-20.1% 🟢)2.402s (-4.3%)2.075s101.00x
▲ VercelExpress0.345s (+46.6% 🔺)2.398s (+12.3% 🔺)2.053s101.05x
▲ VercelNext.js (Turbopack)0.448s (+78.2% 🔺)2.414s (+3.4%)1.965s101.37x

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

workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Express1.099s (-2.3%)2.006s (~)0.907s101.00x
💻 LocalNitro1.099s (-2.8%)2.005s (~)0.906s101.00x
💻 LocalNext.js (Turbopack)1.105s2.005s0.901s101.01x
🐘 PostgresExpress1.105s (-3.6%)2.009s (~)0.904s101.01x
🐘 PostgresNitro1.112s (-2.5%)2.010s (~)0.898s101.01x
🐘 PostgresNext.js (Turbopack)1.148s2.009s0.862s101.04x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express1.555s (-17.1% 🟢)3.521s (-7.5% 🟢)1.966s101.00x
▲ VercelNitro1.653s (-57.5% 🟢)3.300s (-44.1% 🟢)1.647s101.06x
▲ VercelNext.js (Turbopack)1.700s (-16.5% 🟢)3.620s (-5.5% 🟢)1.920s101.09x

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

workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Express10.536s (-3.5%)11.023s (~)0.486s31.00x
💻 LocalNitro10.540s (-3.7%)11.022s (~)0.482s31.00x
🐘 PostgresExpress10.549s (-3.8%)11.023s (~)0.475s31.00x
🐘 PostgresNitro10.590s (-2.6%)11.022s (~)0.432s31.01x
💻 LocalNext.js (Turbopack)10.599s11.021s0.422s31.01x
🐘 PostgresNext.js (Turbopack)10.856s11.018s0.162s31.03x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro14.065s (-40.7% 🟢)16.481s (-34.4% 🟢)2.416s21.00x
▲ VercelNext.js (Turbopack)14.664s (-15.3% 🟢)16.439s (-15.3% 🟢)1.775s21.04x
▲ VercelExpress14.930s (-12.1% 🟢)16.836s (-15.9% 🟢)1.906s21.06x

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

workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro13.714s (-8.9% 🟢)14.027s (-12.5% 🟢)0.313s51.00x
💻 LocalExpress13.781s (-7.9% 🟢)14.027s (-6.7% 🟢)0.246s51.00x
🐘 PostgresExpress13.789s (-5.4% 🟢)14.020s (-6.7% 🟢)0.231s51.01x
🐘 PostgresNitro13.822s (-5.3% 🟢)14.019s (-6.7% 🟢)0.197s51.01x
💻 LocalNext.js (Turbopack)14.053s14.628s0.576s51.02x
🐘 PostgresNext.js (Turbopack)14.473s15.018s0.545s41.06x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro22.846s (-64.6% 🟢)24.190s (-63.7% 🟢)1.343s31.00x
▲ VercelExpress23.828s (-52.6% 🟢)26.319s (-49.9% 🟢)2.491s31.04x
▲ VercelNext.js (Turbopack)24.790s (-52.8% 🟢)25.951s (-52.5% 🟢)1.161s31.09x

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

workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro12.444s (-25.9% 🟢)13.025s (-23.5% 🟢)0.582s71.00x
💻 LocalExpress12.504s (-24.7% 🟢)13.025s (-23.5% 🟢)0.522s71.00x
🐘 PostgresExpress12.510s (-10.7% 🟢)13.020s (-10.8% 🟢)0.510s71.01x
🐘 PostgresNitro12.633s (-9.5% 🟢)13.023s (-9.0% 🟢)0.390s71.02x
💻 LocalNext.js (Turbopack)12.980s13.311s0.331s71.04x
🐘 PostgresNext.js (Turbopack)13.654s14.023s0.369s71.10x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro34.478s (-91.8% 🟢)36.775s (-91.3% 🟢)2.297s31.00x
▲ VercelNext.js (Turbopack)36.647s (-90.7% 🟢)38.422s (-90.3% 🟢)1.775s31.06x
▲ VercelExpress39.195s (-67.7% 🟢)41.529s (-66.4% 🟢)2.333s31.14x

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

Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.187s (-6.9% 🟢)2.008s (~)0.821s151.00x
🐘 PostgresExpress1.190s (-5.6% 🟢)2.008s (~)0.818s151.00x
💻 LocalNitro1.216s (-25.5% 🟢)2.006s (-3.3%)0.790s151.02x
💻 LocalExpress1.230s (-17.4% 🟢)2.006s (~)0.776s151.04x
🐘 PostgresNext.js (Turbopack)1.239s2.007s0.768s151.04x
💻 LocalNext.js (Turbopack)1.278s2.005s0.727s151.08x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express2.770s (-3.2%)4.874s (+5.4% 🔺)2.105s71.00x
▲ VercelNitro2.920s (+3.6%)4.513s (+4.4%)1.593s71.05x
▲ VercelNext.js (Turbopack)53.947s (+1487.7% 🔺)55.472s (+1024.6% 🔺)1.526s619.48x

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

Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.260s (-46.4% 🟢)2.007s (-33.3% 🟢)0.747s151.00x
🐘 PostgresExpress1.261s (-46.6% 🟢)2.008s (-33.3% 🟢)0.747s151.00x
🐘 PostgresNext.js (Turbopack)1.372s2.007s0.635s151.09x
💻 LocalNitro1.631s (-48.1% 🟢)2.005s (-48.4% 🟢)0.374s151.29x
💻 LocalNext.js (Turbopack)1.646s2.005s0.359s151.31x
💻 LocalExpress2.017s (-31.7% 🟢)2.393s (-30.7% 🟢)0.376s131.60x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.619s (-10.7% 🟢)5.094s (-14.0% 🟢)1.475s61.00x
▲ VercelNext.js (Turbopack)3.687s (-48.1% 🟢)5.348s (-39.9% 🟢)1.662s61.02x
▲ VercelExpress4.184s (+15.6% 🔺)5.985s (+17.1% 🔺)1.801s61.16x

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

Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.398s (-59.9% 🟢)2.008s (-49.9% 🟢)0.610s151.00x
🐘 PostgresNitro1.400s (-59.8% 🟢)2.008s (-49.9% 🟢)0.608s151.00x
🐘 PostgresNext.js (Turbopack)1.725s2.151s0.427s141.23x
💻 LocalNext.js (Turbopack)4.041s4.438s0.397s72.89x
💻 LocalNitro4.478s (-46.4% 🟢)5.012s (-44.4% 🟢)0.534s73.20x
💻 LocalExpress6.102s (-26.8% 🟢)6.617s (-26.7% 🟢)0.515s54.37x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.446s (+54.5% 🔺)7.655s (+38.3% 🔺)2.209s41.00x
▲ VercelNext.js (Turbopack)5.928s (-33.5% 🟢)7.957s (-27.4% 🟢)2.029s51.09x
▲ VercelExpress81.654s (+1825.8% 🔺)84.029s (+1271.4% 🔺)2.376s414.99x

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

Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.185s (-5.7% 🟢)2.009s (~)0.824s151.00x
🐘 PostgresNitro1.200s (-4.6%)2.008s (~)0.808s151.01x
🐘 PostgresNext.js (Turbopack)1.243s2.009s0.766s151.05x
💻 LocalNext.js (Turbopack)1.303s2.005s0.702s151.10x
💻 LocalExpress1.538s (-18.8% 🟢)2.007s (-15.1% 🟢)0.469s151.30x
💻 LocalNitro1.593s (-14.6% 🟢)2.006s (-14.3% 🟢)0.413s151.34x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.683s (+9.1% 🔺)4.161s (~)1.478s81.00x
▲ VercelNext.js (Turbopack)2.999s (+2.3%)4.726s (+1.8%)1.726s71.12x
▲ VercelExpress3.593s (+39.2% 🔺)5.054s (+16.2% 🔺)1.461s61.34x

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

Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.269s (-45.8% 🟢)2.009s (-33.3% 🟢)0.740s151.00x
🐘 PostgresNitro1.270s (-45.7% 🟢)2.008s (-33.3% 🟢)0.738s151.00x
🐘 PostgresNext.js (Turbopack)1.382s2.007s0.624s151.09x
💻 LocalNitro1.852s (-39.6% 🟢)2.316s (-40.4% 🟢)0.464s131.46x
💻 LocalNext.js (Turbopack)1.889s2.149s0.260s141.49x
💻 LocalExpress2.130s (-32.0% 🟢)2.675s (-28.9% 🟢)0.545s121.68x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro4.063s (+25.7% 🔺)5.341s (+5.2% 🔺)1.278s61.00x
▲ VercelNext.js (Turbopack)5.424s (+72.6% 🔺)7.896s (+74.6% 🔺)2.471s41.33x
▲ VercelExpress5.653s (+77.1% 🔺)7.651s (+59.6% 🔺)1.998s51.39x

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

Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.407s (-59.6% 🟢)2.009s (-49.9% 🟢)0.602s151.00x
🐘 PostgresExpress1.433s (-59.1% 🟢)2.007s (-50.0% 🟢)0.574s151.02x
🐘 PostgresNext.js (Turbopack)1.652s2.222s0.570s141.17x
💻 LocalNitro4.482s (-51.0% 🟢)5.014s (-50.0% 🟢)0.532s63.19x
💻 LocalNext.js (Turbopack)4.677s5.179s0.501s63.32x
💻 LocalExpress6.254s (-28.9% 🟢)6.615s (-28.7% 🟢)0.361s54.44x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.100s (~)6.970s (+2.2%)1.870s51.00x
▲ VercelExpress5.257s (-18.1% 🟢)6.972s (-14.8% 🟢)1.715s51.03x
▲ VercelNext.js (Turbopack)7.147s (+5.8% 🔺)9.431s (+10.4% 🔺)2.284s41.40x

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

workflow with 10 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.569s (-30.6% 🟢)1.006s (~)0.437s601.00x
🐘 PostgresExpress0.595s (-29.1% 🟢)1.024s (~)0.429s591.04x
💻 LocalExpress0.613s (-37.7% 🟢)1.005s (-6.6% 🟢)0.391s601.08x
💻 LocalNitro0.628s (-36.0% 🟢)1.039s (-5.0%)0.411s581.10x
💻 LocalNext.js (Turbopack)0.779s1.076s0.296s561.37x
🐘 PostgresNext.js (Turbopack)0.863s1.042s0.178s581.52x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.312s (-75.9% 🟢)6.975s (-71.0% 🟢)1.664s91.00x
▲ VercelExpress6.952s (-63.4% 🟢)8.919s (-58.2% 🟢)1.968s71.31x
▲ VercelNext.js (Turbopack)7.009s (-51.7% 🟢)8.825s (-45.1% 🟢)1.816s71.32x

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

workflow with 25 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.351s (-29.9% 🟢)2.008s (-4.4%)0.656s451.00x
🐘 PostgresExpress1.367s (-30.8% 🟢)2.008s (-11.1% 🟢)0.640s451.01x
💻 LocalNitro1.500s (-50.6% 🟢)2.006s (-46.6% 🟢)0.506s451.11x
💻 LocalExpress1.521s (-49.6% 🟢)2.007s (-44.0% 🟢)0.486s451.13x
💻 LocalNext.js (Turbopack)1.760s2.028s0.267s451.30x
🐘 PostgresNext.js (Turbopack)1.967s2.203s0.237s411.46x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro13.225s (-66.5% 🟢)14.968s (-63.8% 🟢)1.743s71.00x
▲ VercelExpress18.195s (-47.3% 🟢)20.304s (-44.8% 🟢)2.110s51.38x
▲ VercelNext.js (Turbopack)18.273s (-63.3% 🟢)20.316s (-60.7% 🟢)2.042s51.38x

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

workflow with 50 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro2.738s (-33.3% 🟢)3.086s (-33.0% 🟢)0.349s391.00x
🐘 PostgresExpress2.742s (-31.3% 🟢)3.086s (-29.4% 🟢)0.344s391.00x
💻 LocalNitro3.229s (-65.3% 🟢)4.010s (-60.0% 🟢)0.780s301.18x
💻 LocalExpress3.271s (-64.5% 🟢)4.009s (-60.0% 🟢)0.738s301.19x
🐘 PostgresNext.js (Turbopack)3.776s4.043s0.267s301.38x
💻 LocalNext.js (Turbopack)3.915s4.181s0.266s291.43x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro29.188s (-69.9% 🟢)30.941s (-68.6% 🟢)1.753s41.00x
▲ VercelExpress36.047s (-72.3% 🟢)38.601s (-70.8% 🟢)2.553s41.23x
▲ VercelNext.js (Turbopack)40.090s (-62.6% 🟢)42.716s (-60.8% 🟢)2.625s31.37x

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

workflow with 10 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.223s (-21.3% 🟢)1.006s (~)0.784s601.00x
🐘 PostgresNext.js (Turbopack)0.256s1.006s0.750s601.15x
🐘 PostgresExpress0.257s (-9.1% 🟢)1.023s (+1.6%)0.767s591.15x
💻 LocalExpress0.432s (-22.9% 🟢)1.004s (~)0.572s601.94x
💻 LocalNitro0.445s (-26.4% 🟢)1.004s (-1.7%)0.559s602.00x
💻 LocalNext.js (Turbopack)0.736s1.148s0.412s533.30x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.189s (+31.8% 🔺)3.630s (+8.3% 🔺)1.441s171.00x
▲ VercelExpress2.572s (+31.6% 🔺)4.332s (+19.1% 🔺)1.759s141.18x
▲ VercelNext.js (Turbopack)2.784s (+37.7% 🔺)4.168s (+9.9% 🔺)1.384s151.27x

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

workflow with 25 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.352s (-29.1% 🟢)1.007s (~)0.655s901.00x
🐘 PostgresExpress0.364s (-28.6% 🟢)1.006s (~)0.643s901.03x
🐘 PostgresNext.js (Turbopack)0.462s1.006s0.544s901.31x
💻 LocalNitro2.061s (-18.8% 🟢)2.579s (-14.3% 🟢)0.519s355.86x
💻 LocalNext.js (Turbopack)2.100s2.737s0.637s335.97x
💻 LocalExpress2.176s (-13.4% 🟢)2.656s (-11.7% 🟢)0.480s346.19x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express5.290s (+73.6% 🔺)6.829s (+42.0% 🔺)1.538s141.00x
▲ VercelNitro5.769s (+78.8% 🔺)7.620s (+58.0% 🔺)1.850s121.09x
▲ VercelNext.js (Turbopack)5.790s (+63.8% 🔺)7.529s (+45.0% 🔺)1.739s121.09x

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

workflow with 50 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.706s (-10.7% 🟢)1.008s (~)0.302s1201.00x
🐘 PostgresExpress0.708s (-13.6% 🟢)1.006s (-1.1%)0.298s1201.00x
🐘 PostgresNext.js (Turbopack)0.937s1.326s0.389s911.33x
💻 LocalNitro9.339s (-16.5% 🟢)9.795s (-16.0% 🟢)0.457s1313.23x
💻 LocalNext.js (Turbopack)9.340s9.874s0.534s1313.23x
💻 LocalExpress9.775s (-12.6% 🟢)10.364s (-13.2% 🟢)0.589s1213.84x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express15.081s (+103.2% 🔺)17.251s (+86.6% 🔺)2.171s71.00x
▲ VercelNitro15.642s (+102.5% 🔺)17.478s (+85.9% 🔺)1.836s71.04x
▲ VercelNext.js (Turbopack)16.640s (+61.1% 🔺)18.399s (+49.8% 🔺)1.759s71.10x

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

Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro1.151s (+438.6% 🔺)2.005s (+99.6% 🔺)0.010s (-20.8% 🟢)2.018s (+98.0% 🔺)0.867s101.00x
💻 LocalNext.js (Turbopack)1.165s2.003s0.008s2.014s0.849s101.01x
🐘 PostgresExpress1.166s (+468.6% 🔺)1.999s (+100.2% 🔺)0.001s (-25.0% 🟢)2.010s (+98.8% 🔺)0.844s101.01x
🐘 PostgresNitro1.171s (+471.4% 🔺)1.999s (+100.0% 🔺)0.002s (+13.3% 🔺)2.012s (+98.9% 🔺)0.840s101.02x
💻 LocalExpress1.173s (+489.0% 🔺)2.006s (+99.7% 🔺)0.013s (+3.3%)2.021s (+98.5% 🔺)0.848s101.02x
🐘 PostgresNext.js (Turbopack)1.220s2.002s0.001s2.011s0.791s101.06x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express2.361s (-5.7% 🟢)3.331s (-18.6% 🟢)2.020s (+110.2% 🔺)5.810s (+3.9%)3.449s101.00x
▲ VercelNitro2.576s (-32.8% 🟢)3.796s (-28.1% 🟢)1.993s (+168.6% 🔺)6.264s (-3.4%)3.687s101.09x
▲ VercelNext.js (Turbopack)2.611s (-61.9% 🟢)3.485s (-59.7% 🟢)2.122s (+235.8% 🔺)6.121s (-37.5% 🟢)3.510s101.11x

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

stream pipeline with 5 transform steps (1MB)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro1.583s (+88.7% 🔺)2.012s (+98.8% 🔺)0.010s (+1.7%)2.023s (+81.3% 🔺)0.440s301.00x
💻 LocalExpress1.594s (+110.5% 🔺)2.012s (+95.5% 🔺)0.009s (+0.9%)2.023s (+94.6% 🔺)0.430s301.01x
🐘 PostgresNitro1.605s (+157.1% 🔺)2.005s (+99.2% 🔺)0.004s (-10.5% 🟢)2.025s (+98.0% 🔺)0.420s301.01x
🐘 PostgresExpress1.622s (+157.4% 🔺)2.006s (+99.3% 🔺)0.004s (~)2.025s (+97.9% 🔺)0.403s301.02x
🐘 PostgresNext.js (Turbopack)1.747s2.010s0.004s2.026s0.279s301.10x
💻 LocalNext.js (Turbopack)1.827s2.010s0.008s2.200s0.373s281.15x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Express6.349s (-2.4%)7.800s (-2.6%)0.474s (+15.9% 🔺)8.743s (-1.0%)2.394s71.00x
▲ VercelNitro6.454s (-78.1% 🟢)7.709s (-75.0% 🟢)0.204s (+82.3% 🔺)8.387s (-73.6% 🟢)1.934s81.02x
▲ VercelNext.js (Turbopack)6.519s (-61.5% 🟢)7.670s (-58.0% 🟢)0.202s (-4.6%)8.282s (-56.3% 🟢)1.763s81.03x

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

10 parallel streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.723s (-25.4% 🟢)0.999s (-19.9% 🟢)0.000s (-18.6% 🟢)1.023s (-18.7% 🟢)0.300s591.00x
🐘 PostgresExpress0.760s (-20.9% 🟢)1.069s (-16.3% 🟢)0.000s (-20.7% 🟢)1.084s (-17.0% 🟢)0.325s581.05x
🐘 PostgresNext.js (Turbopack)0.831s1.090s0.000s1.100s0.269s551.15x
💻 LocalNext.js (Turbopack)1.319s1.979s0.000s1.982s0.663s311.82x
💻 LocalNitro1.430s (+16.9% 🔺)2.014s (~)0.000s (+100.0% 🔺)2.016s (~)0.586s301.98x
💻 LocalExpress1.448s (+18.2% 🔺)2.014s (~)0.000s (-30.0% 🟢)2.016s (~)0.568s302.00x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.633s (+19.1% 🔺)4.574s (+4.1%)0.001s (+766.7% 🔺)5.041s (+4.8%)1.409s121.00x
▲ VercelExpress3.953s (+5.7% 🔺)5.235s (+2.6%)0.000s (-100.0% 🟢)5.684s (+2.8%)1.732s111.09x
▲ VercelNext.js (Turbopack)3.993s (-60.8% 🟢)5.121s (-55.5% 🟢)0.000s (NaN%)5.530s (-54.1% 🟢)1.537s111.10x

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

fan-out fan-in 10 streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.436s (-19.0% 🟢)2.140s (-1.7%)0.000s (NaN%)2.153s (-2.1%)0.717s281.00x
🐘 PostgresNitro1.502s (-16.2% 🟢)2.175s (+1.6%)0.000s (-100.0% 🟢)2.196s (+1.0%)0.694s281.05x
🐘 PostgresNext.js (Turbopack)1.715s2.311s0.000s2.318s0.603s261.19x
💻 LocalNext.js (Turbopack)2.552s3.125s0.001s3.129s0.577s201.78x
💻 LocalNitro3.227s (-4.8%)3.898s (-3.3%)0.000s (-53.1% 🟢)3.905s (-3.2%)0.679s162.25x
💻 LocalExpress3.532s (+1.9%)3.897s (-3.4%)0.000s (-41.7% 🟢)4.235s (+4.9%)0.703s152.46x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.368s (+31.1% 🔺)6.435s (+19.7% 🔺)0.001s (+266.7% 🔺)6.840s (+18.1% 🔺)1.471s91.00x
▲ VercelExpress6.219s (+35.6% 🔺)7.317s (+21.5% 🔺)0.000s (+Infinity% 🔺)7.979s (+23.6% 🔺)1.760s81.16x
▲ VercelNext.js (Turbopack)6.558s (+16.8% 🔺)8.018s (+14.8% 🔺)0.001s (+300.0% 🔺)8.401s (+11.4% 🔺)1.843s81.22x

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

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro13/21
🐘 PostgresNitro11/21
▲ VercelNitro15/21
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express🐘 Postgres15/21
Next.js (Turbopack)🐘 Postgres13/21
Nitro🐘 Postgres14/21
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)
  • 🌐 Redis: Community world (local development)
  • 🌐 Redis + BullMQ: Community world (local development)
  • 🌐 Cloudflare: Community world (local development)
  • 🌐 MySQL: Community world (local development)
  • 🌐 Azure: Community world (local development)
  • 🌐 NATS JetStream: Community world (local development)
  • 🌐 Upstash: Community world (local development)

📋 View full workflow run

@pranaygp
pranaygp marked this pull request as ready for review May 28, 2026 22:49
@pranaygp
pranaygp requested a review from a team as a code ownerMay 28, 2026 22:49
CopilotAI review requested due to automatic review settings May 28, 2026 22:49

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

Prevents stream write failures from surfacing as unhandledRejection before the step runtime collects them via ops, and enriches Vercel stream HTTP errors with the request endpoint and Vercel correlation headers.

Changes:

  • Attach a no-op .catch() to FlushableStreamState.promise at creation so early rejections are observed before the runtime awaits them.
  • Centralize Vercel stream write/close error construction in createStreamRequestError(), including PUT URL plus x-vercel-id / x-vercel-error headers.
  • Add tests for unhandled-rejection behavior and Vercel error diagnostics, plus a patch changeset.

Reviewed changes

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

Show a summary per file
FileDescription
packages/core/src/flushable-stream.tsAdds no-op rejection observer on state.promise in createFlushableState.
packages/core/src/flushable-stream.test.tsNew test verifying no unhandledRejection is emitted on early state rejection.
packages/world-vercel/src/streamer.tsAdds createStreamRequestError helper; uses it in write/writeMulti/close failures.
packages/world-vercel/src/streamer.test.tsNew test asserting endpoint and Vercel correlation headers appear in the failure message.
.changeset/stream-failure-diagnostics.mdPatch changeset for @workflow/core and @workflow/world-vercel.

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

@TooTallNateTooTallNate 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.

Approve — correct fix for a real bug, with a strong regression test

Two changes:

  1. createFlushableState attaches a no-op .catch(() => {}) to state.promise at creation time, so an early rejection (before the runtime collects state.promise into its ops array and awaits it) doesn't fire unhandledRejection.
  2. world-vercel stream errors now include PUT <url> + x-vercel-id + x-vercel-error headers in the error message — useful for tracing transient stream failures back to a specific Vercel function invocation.

Why this fix is correct

The .catch(() => {}) is a standard Node.js pattern for "this rejection will be observed later." It does not swallow the error:

  • .catch() returns a NEW promise that resolves (because the handler returned undefined).
  • The original state.promise is still rejected and still surfaces the same rejection when later awaited.
  • Both .then()/.catch() chains on the same promise observe the same rejection — they don't compete.

I traced where state.promise is consumed: serialization.ts (×6 sites) and writable-stream.ts all ops.push(state.promise), and the runtime does await Promise.all(ops) after user code returns. So the rejection still propagates through the normal error path. ✓

Test design is excellent

The new test (does not emit an unhandled rejection before the runtime awaits a failed operation):

  1. Listens for process.on('unhandledRejection').
  2. Creates state, rejects it, waits a tick (long enough for Node to fire unhandledRejection if it would).
  3. Asserts no unhandledRejection fired AND state.promise still rejects when awaited.

The second assertion is critical — it proves the fix didn't accidentally swallow the rejection.

I verified the test fails without the fix by temporarily removing the .catch() line:

expected [] to deeply equal [
Error { "message": "Stream write failed" }
]

So the test correctly catches the regression it's protecting against.

What I verified locally

  • pnpm install --frozen-lockfile
  • pnpm turbo run build --filter @workflow/core --filter @workflow/world-vercel
  • cd packages/core && pnpm exec vitest run src/flushable-stream.test.ts ✓ (10/10)
  • pnpm --filter @workflow/world-vercel test ✓ (110/110)
  • Reverted the .catch(() => {}) line and confirmed the regression test fails as expected — proves the test isn't a vacuous pass.

CI

106 success, 5 failures, all unrelated:

  • E2E Vercel Prod Tests (vite) — single workflow run flake on Vercel infrastructure
  • Benchmark Vercel/Local (nitro-v3) — main also fails these regularly
  • Benchmark Community World (Redis + BullMQ) — unrelated to flushable-stream
  • E2E Required Check — meta-check failing because the above failed

Restraint on retry is the right call

The PR body's note about not adding automatic retries is exactly right. Stream writes aren't idempotent server-side, and a response error after server-accepted bytes can't be distinguished from a pre-accept network failure — blindly retrying could duplicate chunks. The diagnostic improvement (request correlation headers in the error) is the better incremental win: now when a stream write fails, the user has the Vercel request ID to look up server-side state.

Approving.

@pranaygp
pranaygp enabled auto-merge (squash) May 28, 2026 23:19
@pranaygp
pranaygp merged commit ae37315 into mainMay 28, 2026
198 of 210 checks passed
@pranaygp
pranaygp deleted the pranaygp/codex/stream-write-failure-handling branch May 28, 2026 23:33
@github-actionsgithub-actionsBot mentioned this pull request May 28, 2026
github-actionsBot added a commit that referenced this pull request May 28, 2026
Signed-off-by: Pranay Prakash <pranay.gp@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

Backport PR opened against stable: #2149. Merge conflicts were resolved by AI — please review carefully. (backport job run)

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.

3 participants

@pranaygp@TooTallNate