Backport #4179: fix: retry backend connection failures and improve error logs - #4190
Merged
Merged
Conversation
* fix(world-vercel): treat every response-less fetch failure as a transport failure `makeRequest` and `instrumentedFetch` only wrapped a `fetch` rejection as a retryable `TRANSPORT` / `STREAM_ERROR` when `getTransientTransportCode` found a code from a fixed allowlist on the error or its `cause` chain. Anything else was rethrown raw, and a raw `TypeError: fetch failed` is indistinguishable from a user throw by the time it reaches `classifyRunError`: the run failed as `USER_ERROR`, attributing a backend outage to customer code, and `isRetryableWorldError` never redelivered the queue message. The allowlist can only ever name failures someone has already seen, and the ones it misses are ordinary: h2 session errors (`ERR_HTTP2_GOAWAY_SESSION` — the shared events pool negotiates h2), TLS handshake failures, `ENETUNREACH`, and the `AggregateError` a happy-eyeballs connect raises, which hangs its codes off `errors[]` where a `cause` walk cannot see them. A rejection from `fetch` / `nodeHttpFetch` means no response was produced at all, so `describeTransportFailure` inverts the default: everything is a transport failure unless it is a request-construction fault (`ERR_INVALID_URL` and friends), which is permanent and must keep failing fast rather than burning the run's delivery budget re-forming the same broken request. Known codes still name themselves in the message, so existing failures report exactly what they reported before, including the `UND_ERR_CONNECT_TIMEOUT` retry branch. Agent selection and `Request` construction move out of the try blocks so the catch only ever sees the request on the wire. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-Authored-By: Karthik Kalyan <105607645+karthikscale3@users.noreply.github.com> * fix(core): render a failed run's error cause chain in the run-failure log The run-failure log prints `errorMessage` and the source-map-remapped `errorStack`, and neither says anything when the terminal error is a wrapper. `TypeError: fetch failed` is the canonical case: undici's wrapper carries that fixed message by design and a stack of pure `node:internal/` frames, all of which the formatter's framework-frame trim drops. The socket, DNS or TLS failure that actually happened lives one or two `cause` hops down, and nothing in the log pipeline read it. Same for the world layer's own wrapping, where the wrapper names the request and the cause names what went wrong with it. `formatErrorCauseChain` summarizes the chain, one `Name: message (CODE)` line per link, skipping the value itself (the log already prints that) and summarizing an `AggregateError`'s collected attempts, which is where a happy-eyeballs connect reports every address it tried. `composeLogLine` renders it as a `cause` row under the message it explains, and skips it when the stack body already spells the chain out. The field is undefined when there is no cause, so an ordinary user throw logs exactly as before. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-Authored-By: Karthik Kalyan <105607645+karthikscale3@users.noreply.github.com> * chore: combine transport and run failure changesets * fix: guard cause logging and reject unsupported backend URLs * docs: clarify retry behavior in changeset * fix: preserve Fetch blocked-port errors without retrying * fix: classify v4 response stream failures * fix: reject credential-bearing backend URLs * fix: recycle failed HTTP/2 sessions and document recovery * fix: preserve event-write retries and reject invalid request headers --------- Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com> Co-authored-by: Peter Wielander <mittgfu@gmail.com> Signed-off-by: Karthik Kalyan <105607645+karthikscale3@users.noreply.github.com>
🦋 Changeset detectedLatest commit: 2ae55c9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 17 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 |
Contributor
Contributor
Author
🧪 E2E Test Results❌ Some tests failed Summary
❌ Failed Tests▲ Vercel Production (1 failed)hono (1 failed):
🌍 Community Worlds (106 failed)redis (21 failed):
turso (85 failed):
Details by Category❌ ▲ Vercel Production
✅ 💻 Local Development
✅ 📦 Local Production
✅ 🐘 Local Postgres
✅ 🪟 Windows
❌ 🌍 Community Worlds
✅ 📋 Other
❌ Some E2E test jobs failed:
Check the workflow run for details. |
VaguelySerious
approved these changes
Sep 16, 2026
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automated backport of #4179 to
stable(backport job run).AI recommendation: This is a correctness fix for behavior that exists on
stable: response-lessfetchfailures (h2 GOAWAY, TLS,ENETUNREACH, happy-eyeballsAggregateError) propagated raw and were classified asUSER_ERROR, so backend outages failed runs without queue redelivery. The supporting changes (recycling failed HTTP/2 sessions, rejecting permanently-broken requests fast, and rendering the error cause chain in failure logs) are all in service of that defect rather than new capability. Note thatpackages/core/src/log-format.tsand thedocs/content/docs/v5/path do not exist onstable, so the cherry-pick will need manual adaptation of the log-rendering and docs portions.Merge conflicts were resolved by AI (opencode with
anthropic/claude-opus-5). Please review the conflict resolution carefully before merging.