SIGN IN SIGN UP

fix: retry backend connection failures and improve error logs (#4179)

* 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>
K
Karthik Kalyan committed
5dbbcf91d92a4cf8fd8f96b170d037749ab0b1ef
Parent: 56322af
Committed by GitHub <noreply@github.com> on 9/16/2026, 12:34:19 AM