fix(streams): surface typed retention expiry errors - #3410
Conversation
🦋 Changeset detectedLatest commit: 6fd2b95 The changes in this PR will be included in the next version bump. This PR includes changesets to release 20 packages
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 |
📊 Workflow Benchmarkscommit Backend:
📈 STSO distribution vs main (inline / queue-hop histograms)1020 steps (inline) Cumulative STSO time: main 153980ms → this run 156666ms (Δ +2686ms, +2%) 📜 Previous results (1)fed5233Mon, 10 Aug 2026 16:06:00 GMT · run logs
ℹ️ Metric definitions & methodologyThe 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: Best/P75/P90/P99 deltas compare against the most recent benchmark run on 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 ( Cold starts are kept in the numbers on purpose — they are part of real bursty-workload latency. The workbench deployment cold-starts the |
🧪 E2E Test Results✅ All tests passed E2E Test SummarySummary
Details by Category✅ ▲ Vercel Production
✅ 💻 Local Development
✅ 📦 Local Production
✅ 🐘 Local Postgres
✅ 🪟 Windows
✅ vercel-multi-region
|
| }), | ||
| buildError: (res) => | ||
| new Error(`Failed to fetch stream: ${res.status}`), | ||
| buildError: createStreamReadError, |
There was a problem hiding this comment.
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>
fed5233 to
6fd2b95
Compare
karthikscale3
left a comment
There was a problem hiding this comment.
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.
|
No backport to This is primarily additive API surface: it introduces a new exported To override, re-run the Backport to stable workflow manually via |
Summary & Motivation
Adds
StreamExpiredErrorto@workflow/errors, carrying the run, stream, and server-reported expiry timestamp from workflow-server's 410stream-expiredenvelope. 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.