Repository navigation
fix(app): retry transport errors wrapped by the client - #49426
Merged
Merged
Conversation
The generated client wraps every fetch failure as ClientError("Transport", { cause }),
so the message-based transient check in @opencode/util/retry never saw "Failed to fetch"
and gave up on the first dropped loopback request. Walk the cause chain and include
Node/Bun error codes.
Refs anomalyco#46651
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
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.
Refs #46651
The reporter's netlog shows the real failure: the sidecar passed readiness, then Chromium aborted the loopback bootstrap requests with
ERR_NETWORK_CHANGED(Windows adapter reconfiguration right after login, or Wi-Fi/VPN flaps mid-session). That surfaces to JS asTypeError: Failed to fetch, and the app never recovered.On
v2the bootstrap already wraps those requests inretry(...), but the retry never fired:packages/client/src/promise/generated/client.ts:311-318wraps every fetch rejection asClientError("Transport", { cause }), whosemessageis the literal"Transport".packages/util/src/retry.tsmatched transient text againsterror.messageonly, so the"Failed to fetch"oncausewas invisible.health.ts:65already checkserror.reason === "Transport";retry.tswas never reconciled with the v2 client.Measured through the real stack (
createRequestQueue→OpenCode.make→retry) in Chrome 153 against a closed127.0.0.1port:retry(() => fetch(...))— raw browser fetchretry(() => api.project.list())— app client stackFix
isTransientErrornow walks thecausechain and also readscode, which is where Bun/Node put the network detail (ECONNRESETwith a generic message):Affected call sites:
bootstrap.ts:66, 152andworkspaces/location.tsx:40.Tests use real sockets (a TCP listener that resets the first connections, then serves
/api/project) rather than thrown fakes; both fail on the previousretry.ts.Not addressed here
Unary request failures still do not trigger the sidecar
reconnectpath; only the SSE stream dropping does (packages/client/src/solid/connection.ts:147-183). That covers the "never reconnects until restart" report and is a separate change.