Skip to content

fix(streams): surface typed retention expiry errors - #3410

Merged
alangenfeld merged 1 commit into
mainfrom
alangenfeld/workflow-stream-expired-plan
Aug 11, 2026
Merged

fix(streams): surface typed retention expiry errors#3410
alangenfeld merged 1 commit into
mainfrom
alangenfeld/workflow-stream-expired-plan

Conversation

@alangenfeld

@alangenfeld alangenfeld commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Summary & Motivation

Adds StreamExpiredError to @workflow/errors, carrying the run, stream, and server-reported expiry timestamp from workflow-server's 410 stream-expired envelope. The reconnect loop rethrows it instead of retrying, since retention expiry is terminal and a retry budget would only convert it into a generic exhaustion error.

Test Plan

Unit tests added for the 410 decoding path and the reconnect rethrow; typechecks pass across the touched packages.

@changeset-bot

changeset-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6fd2b95

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

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

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview Aug 10, 2026 5:50pm
example-nextjs-workflow-webpack Ready Ready Preview Aug 10, 2026 5:50pm
example-workflow Ready Ready Preview Aug 10, 2026 5:50pm
workbench-astro-workflow Ready Ready Preview Aug 10, 2026 5:50pm
workbench-express-workflow Ready Ready Preview Aug 10, 2026 5:50pm
workbench-fastify-workflow Ready Ready Preview Aug 10, 2026 5:50pm
workbench-hono-workflow Ready Ready Preview Aug 10, 2026 5:50pm
workbench-nestjs-workflow Ready Ready Preview Aug 10, 2026 5:50pm
workbench-nitro-workflow Ready Ready Preview Aug 10, 2026 5:50pm
workbench-nuxt-workflow Ready Ready Preview Aug 10, 2026 5:50pm
workbench-python-workflow Error Error Aug 10, 2026 5:50pm
workbench-sveltekit-workflow Ready Ready Preview Aug 10, 2026 5:50pm
workbench-tanstack-start-workflow Ready Ready Preview Aug 10, 2026 5:50pm
workbench-vite-workflow Ready Ready Preview Aug 10, 2026 5:50pm
workflow-docs Ready Ready Preview, v0 Aug 10, 2026 5:50pm
workflow-swc-playground Ready Ready Preview Aug 10, 2026 5:50pm
workflow-tarballs Ready Ready Preview Aug 10, 2026 5:50pm
workflow-web Ready Ready Preview Aug 10, 2026 5:50pm

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

📊 Workflow Benchmarks

commit 6fd2b95 · Mon, 10 Aug 2026 18:04:54 GMT · run logs

Backend: vercel · app: nextjs-turbopack

Metric Scenario Best (ms) P75 (ms) P90 (ms) P99 (ms) Samples
TTFS step 207 (-9.2%) 1499 🔴 (+38%) 🔻 1534 🔴 (+37%) 🔻 1744 🔴 (+46%) 🔻 30
TTFS stream 182 (-18%) 💚 1440 🔴 (+33%) 🔻 1516 🔴 (+38%) 🔻 1874 🔴 (+59%) 🔻 30
TTFS hook + stream 374 (+10%) 1700 🔴 (+28%) 🔻 1767 🔴 (+29%) 🔻 1938 🔴 (+29%) 🔻 30
STSO 1020 steps (inline) 106 (-0.9%) 160 (+2.6%) 191 (+6.7%) 353 (+11%) 1019
WO 1020 steps 157928 (+1.9%) 157928 (+1.9%) 157928 (+1.9%) 157928 (+1.9%) 1
SL stream latency 106 (+13%) 178 🔴 (+23%) 🔻 248 🔴 (+31%) 🔻 410 🔴 (-49%) 💚 30
SO stream overhead (text) 125 (-11%) 235 (-18%) 💚 311 (-2.8%) 1385 🔴 (-0.5%) 30
SO stream overhead (structured) 134 (-7.6%) 344 🔴 (-23%) 💚 708 🔴 (-15%) 💚 862 (-20%) 💚 30
📈 STSO distribution vs main (inline / queue-hop histograms)

1020 steps (inline)

Cumulative STSO time: main 153980ms → this run 156666ms (Δ +2686ms, +2%)

100-150 ms  ██████████████████████┃█  main 677  this 639   -38
150-200 ms  █████████┃                main 282  this 294   +12
200-250 ms  █┃                        main  31  this  44   +13
250-300 ms  ┃                         main  15  this  14    -1
300-350 ms  ┃                         main   7  this  17   +10
350-400 ms  ┃                         main   1  this   5    +4
400-450 ms  ┃                         main   2  this   3    +1
450-500 ms  ┃                         main   2  this   1    -1
500-550 ms  ┃                         main   0  this   1    +1
550-600 ms  ┃                         main   0  this   1    +1
900-950 ms  ┃                         main   2  this   0    -2
📜 Previous results (1)

fed5233

Mon, 10 Aug 2026 16:06:00 GMT · run logs

vercel / nextjs-turbopack

Metric Scenario Best (ms) P75 (ms) P90 (ms) P99 (ms) Samples
TTFS step 1218 (+434%) 🔻 1477 🔴 (+36%) 🔻 1502 🔴 (+34%) 🔻 1558 🔴 (+30%) 🔻 30
TTFS stream 1407 (+537%) 🔻 1475 🔴 (+36%) 🔻 1490 🔴 (+36%) 🔻 1562 🔴 (+32%) 🔻 30
TTFS hook + stream 1442 (+324%) 🔻 1627 🔴 (+22%) 🔻 1687 🔴 (+24%) 🔻 1837 🔴 (+22%) 🔻 30
STSO 1020 steps (inline) 65 (-39%) 💚 128 (-18%) 💚 148 (-17%) 💚 243 (-24%) 💚 1019
WO 1020 steps 129020 (-17%) 💚 129020 (-17%) 💚 129020 (-17%) 💚 129020 (-17%) 💚 1
SL stream latency 84 (-11%) 116 🔴 (-20%) 💚 131 🔴 (-31%) 💚 179 🔴 (-78%) 💚 30
SO stream overhead (text) 112 (-20%) 💚 161 (-44%) 💚 178 (-44%) 💚 206 (-85%) 💚 30
SO stream overhead (structured) 103 (-29%) 💚 153 (-66%) 💚 184 (-78%) 💚 475 (-56%) 💚 30
ℹ️ Metric definitions & methodology

The collapsed STSO distribution section above buckets every step gap of the sequential-steps run (not a sampled window), split by whether the step ending the gap ran inline — in the same warm process as the step before it, so the gap is pure framework overhead — or after a queue-hop — the first step of a fresh process, which pays queue dispatch, client reinit and event-log replay. Bars overlay the two runs: is main, marks where this run lands, bridges the gap when this run has more samples in a bucket.

Best/P75/P90/P99 deltas compare against the most recent benchmark run on main at the time of this run. 🔻 flags a delta worse than +15%, 💚 one better than −15%.

Metrics — TTFS: time to first step body (in-deployment start() → first step body, deployment clocks) · STSO: step-to-step overhead (gap between consecutive step bodies) · WO: workflow overhead (whole-run time outside step bodies, in-deployment anchored) · SL: stream latency (in-deployment write → read propagation, readAt - writtenAt) · SO: stream overhead (end-to-end write+consume time beyond the modelled generation window)

Scenarios — step: one trivial no-op step, no stream; no hooks, so the run stays in turbo mode (in-process fast path) · stream: one streaming step; no hooks, so the run stays in turbo mode (in-process fast path) · hook + stream: registers a hook before one step, which exits turbo mode (dispatch path) · 1020 steps: 1020 trivial sequential steps; STSO is measured between consecutive steps in the given step ranges, and WO is the whole-run overhead outside step bodies · stream latency: parallel reader/writer steps on a dedicated stream; SL is the in-deployment write->read propagation (readAt - writtenAt) · stream overhead (text): writer streams 300 variable-length text token deltas paced at 100/s for 3s (a haiku-size LLM's token throughput) while a parallel reader drains the whole stream; SO is the end-to-end write+consume time beyond the 3s generation window (overhead/backpressure) · stream overhead (structured): same workload as stream overhead (text), but each delta is an AI-SDK-style structured object ({ type: 'text-delta', id, text }) instead of a raw string, so the SO gap vs the text scenario is the added serialization cost

🔴 marks a percentile over its target (within target is left unmarked). Targets (p75/p90/p99, ms) — TTFS 200/300/600 · SL 50/60/125 · SO 250/500/1000

All metrics are measured from deployment-side timestamps only. Runs are triggered by an in-deployment route that stamps the anchor (clientStart) right before start(), so the CI runner’s request and its path through api.vercel.com sit outside every measured window. TTFS = in-deployment start() → first step body (turbo uses the in-process fast path, non-turbo the dispatch path), and includes the VQS dispatch hop plus any /flow cold start. STSO/WO are measured between step bodies on the deployment. SL is measured inside the workflow (parallel reader/writer steps), so it no longer includes the api.vercel.com read path.

Cold starts are kept in the numbers on purpose — they are part of real bursty-workload latency. The workbench deployment cold-starts the /flow invocation for a large fraction of runs, inflating P75+; the Best column shows the fastest (warm-start) sample for comparison.

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

E2E Test Summary

Summary
Passed Failed Skipped Total
✅ ▲ Vercel Production 3466 0 590 4056
✅ 💻 Local Development 3810 0 558 4368
✅ 📦 Local Production 3810 0 558 4368
✅ 🐘 Local Postgres 3810 0 558 4368
✅ 🪟 Windows 312 0 0 312
✅ vercel-multi-region 27 0 0 27
Total 15235 0 2264 17499
Details by Category

✅ ▲ Vercel Production

App Passed Failed Skipped
✅ astro-node 128 0 28
✅ astro-quickjs 128 0 28
✅ example-node 128 0 28
✅ example-quickjs 128 0 28
✅ express-node 128 0 28
✅ express-quickjs 128 0 28
✅ fastify-node 128 0 28
✅ fastify-quickjs 128 0 28
✅ hono-node 128 0 28
✅ hono-quickjs 128 0 28
✅ nest-node 128 0 28
✅ nest-quickjs 128 0 28
✅ nextjs-turbopack-node 153 0 3
✅ nextjs-turbopack-quickjs 153 0 3
✅ nextjs-webpack-node 153 0 3
✅ nextjs-webpack-quickjs 153 0 3
✅ nitro-node 128 0 28
✅ nitro-quickjs 128 0 28
✅ nuxt-node 128 0 28
✅ nuxt-quickjs 128 0 28
✅ sveltekit-node 147 0 9
✅ sveltekit-quickjs 147 0 9
✅ tanstack-start-node 128 0 28
✅ tanstack-start-quickjs 128 0 28
✅ vite-node 128 0 28
✅ vite-quickjs 128 0 28

✅ 💻 Local Development

App Passed Failed Skipped
✅ astro-stable-node 130 0 26
✅ astro-stable-quickjs 130 0 26
✅ express-stable-node 130 0 26
✅ express-stable-quickjs 130 0 26
✅ fastify-stable-node 130 0 26
✅ fastify-stable-quickjs 130 0 26
✅ hono-stable-node 130 0 26
✅ hono-stable-quickjs 130 0 26
✅ nest-stable-node 130 0 26
✅ nest-stable-quickjs 130 0 26
✅ nextjs-turbopack-canary-node 137 0 19
✅ nextjs-turbopack-canary-quickjs 137 0 19
✅ nextjs-turbopack-stable-node 156 0 0
✅ nextjs-turbopack-stable-quickjs 156 0 0
✅ nextjs-webpack-canary-node 137 0 19
✅ nextjs-webpack-canary-quickjs 137 0 19
✅ nextjs-webpack-stable-node 156 0 0
✅ nextjs-webpack-stable-quickjs 156 0 0
✅ nitro-stable-node 130 0 26
✅ nitro-stable-quickjs 130 0 26
✅ nuxt-stable-node 130 0 26
✅ nuxt-stable-quickjs 130 0 26
✅ sveltekit-stable-node 149 0 7
✅ sveltekit-stable-quickjs 149 0 7
✅ tanstack-start-node 130 0 26
✅ tanstack-start-quickjs 130 0 26
✅ vite-stable-node 130 0 26
✅ vite-stable-quickjs 130 0 26

✅ 📦 Local Production

App Passed Failed Skipped
✅ astro-stable-node 130 0 26
✅ astro-stable-quickjs 130 0 26
✅ express-stable-node 130 0 26
✅ express-stable-quickjs 130 0 26
✅ fastify-stable-node 130 0 26
✅ fastify-stable-quickjs 130 0 26
✅ hono-stable-node 130 0 26
✅ hono-stable-quickjs 130 0 26
✅ nest-stable-node 130 0 26
✅ nest-stable-quickjs 130 0 26
✅ nextjs-turbopack-canary-node 137 0 19
✅ nextjs-turbopack-canary-quickjs 137 0 19
✅ nextjs-turbopack-stable-node 156 0 0
✅ nextjs-turbopack-stable-quickjs 156 0 0
✅ nextjs-webpack-canary-node 137 0 19
✅ nextjs-webpack-canary-quickjs 137 0 19
✅ nextjs-webpack-stable-node 156 0 0
✅ nextjs-webpack-stable-quickjs 156 0 0
✅ nitro-stable-node 130 0 26
✅ nitro-stable-quickjs 130 0 26
✅ nuxt-stable-node 130 0 26
✅ nuxt-stable-quickjs 130 0 26
✅ sveltekit-stable-node 149 0 7
✅ sveltekit-stable-quickjs 149 0 7
✅ tanstack-start-node 130 0 26
✅ tanstack-start-quickjs 130 0 26
✅ vite-stable-node 130 0 26
✅ vite-stable-quickjs 130 0 26

✅ 🐘 Local Postgres

App Passed Failed Skipped
✅ astro-stable-node 130 0 26
✅ astro-stable-quickjs 130 0 26
✅ express-stable-node 130 0 26
✅ express-stable-quickjs 130 0 26
✅ fastify-stable-node 130 0 26
✅ fastify-stable-quickjs 130 0 26
✅ hono-stable-node 130 0 26
✅ hono-stable-quickjs 130 0 26
✅ nest-stable-node 130 0 26
✅ nest-stable-quickjs 130 0 26
✅ nextjs-turbopack-canary-node 137 0 19
✅ nextjs-turbopack-canary-quickjs 137 0 19
✅ nextjs-turbopack-stable-node 156 0 0
✅ nextjs-turbopack-stable-quickjs 156 0 0
✅ nextjs-webpack-canary-node 137 0 19
✅ nextjs-webpack-canary-quickjs 137 0 19
✅ nextjs-webpack-stable-node 156 0 0
✅ nextjs-webpack-stable-quickjs 156 0 0
✅ nitro-stable-node 130 0 26
✅ nitro-stable-quickjs 130 0 26
✅ nuxt-stable-node 130 0 26
✅ nuxt-stable-quickjs 130 0 26
✅ sveltekit-stable-node 149 0 7
✅ sveltekit-stable-quickjs 149 0 7
✅ tanstack-start-node 130 0 26
✅ tanstack-start-quickjs 130 0 26
✅ vite-stable-node 130 0 26
✅ vite-stable-quickjs 130 0 26

✅ 🪟 Windows

App Passed Failed Skipped
✅ nextjs-turbopack-node 156 0 0
✅ nextjs-turbopack-quickjs 156 0 0

✅ vercel-multi-region

App Passed Failed Skipped
✅ nextjs-turbopack 27 0 0

📋 View full workflow run

@alangenfeld
alangenfeld marked this pull request as ready for review August 10, 2026 16:37
@alangenfeld
alangenfeld requested a review from a team as a code owner August 10, 2026 16:37
}),
buildError: (res) =>
new Error(`Failed to fetch stream: ${res.status}`),
buildError: createStreamReadError,

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.

AI + Human review: This structured decoder is only wired into streams.get(), but the paired server PR now returns the same 410 stream-expired envelope from the chunk-list and stream-info endpoints. getChunks() and getInfo() still use makeRequest(), whose shared mapper converts every 410 to RunExpiredError and drops runId, streamId, and expiredAt; WorkflowReadableStream.getTailIndex() therefore also exposes the wrong type. Please reuse this decoding logic for those calls, or teach the shared mapper to construct StreamExpiredError from the error code/details, and add coverage for both endpoints.

Signed-off-by: Alex Langenfeld <alex.langenfeld@vercel.com>

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

AI + Human review: Re-reviewed at 6fd2b95. Stream expiry decoding is now centralized in the shared 410 mapper, preserves structured details, and is covered for direct reads, chunks, info, and reconnect termination. Looks good.

@alangenfeld
alangenfeld merged commit c1a5c74 into main Aug 11, 2026
293 of 296 checks passed
@alangenfeld
alangenfeld deleted the alangenfeld/workflow-stream-expired-plan branch August 11, 2026 19:52
@github-actions

Copy link
Copy Markdown
Contributor

No backport to stable for c1a5c74 (AI decision).

This is primarily additive API surface: it introduces a new exported StreamExpiredError class in @workflow/errors (with new runId/streamId/expiredAt fields), a new Accept: application/json request header on the stream-read path, and new details plumbing through errorForResponse/makeRequeststable's errorForResponse opts do not even have a details field, so it builds on a main-only signature. The genuine fix portion is the reconnect loop in packages/core/src/serialization.ts rethrowing a terminal retention-expiry error instead of burning the whole reconnect budget and surfacing a generic exhaustion error; a human could split that out and force a backport via workflow_dispatch if the wasted retries matter on the maintenance line.

To override, re-run the Backport to stable workflow manually via workflow_dispatch and paste this commit SHA into the ref input:

c1a5c74edb2fad84eb5bbc2036bf73cbd16ca28d

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