provider: Zen's free models go out through Bun, which Zen serves them to (biubiubiuzone on X)
magpie 0.1.4349 on macOS: with an OpenCode Zen key set, deepseek and the
other free models failed, while the same key worked in the OpenCode app.
Cause: Zen's free tier tells OpenCode from other clients by the
connection, not the request. I captured the bytes real OpenCode 2.3.0
sent (through a recording Bun relay) and replayed them from one computer
(mica) within a minute:
- Bun 1.4.2 (magpie's BunVersion) and Bun 1.4.4 (OpenCode's own) got 200.
- Go's net/http and curl got 429 FreeUsageLimitError, "Free usage limit
reached. Free models work in OpenCode", over HTTP/1.1 and HTTP/2, with
the public key or a user's own.
Zen's server source (console/app/src/routes/zen/util/handler.ts) runs
the free model's rate limiter before authenticate(), so a key never
lifts it.
Fix:
- netproxy.Elsewhere is a hook every Dispatch transport asks first.
- internal/provider sets it (zen_bun.go). A request to an OpenCode host's
/inference/ paths (Zen's free tier, OpenCodeFreeURL) goes through the
plugin host's fetch, which is Bun's, with its own headers and body and
the proxy chosen in its context.
- The host is told a provider id no plugin claims, so no plugin's
sign-in or fetch takes the request over.
- This covers the gateway's turns, the Test button and
RetryOpenCodeFreeOnZen.
- Where Bun can't be had (HasBun false after the fetch failed), the
request goes through Go as before.
- Zen's paid paths (/zen/v1, /zen/go/v1) stay in Go.
Run:
- New tests: TestZenFreeTierGoesThroughBun, TestZenPaidAndOthersStayInGo
and TestZenFreeTierWithoutBun. With the hook not set (init's assignment
taken out by hand), the first and third are red ("dialed").
- Real end to end on mica, in a sandbox HOME, through
provider.FromPreset("opencode-zen").TestModels with the public key:
- this change: deepseek-v4.1-flash-free, big-pickle and
mimo-v2.6-flash-free gave 200, every time;
- with Elsewhere set to nil (the old path): all three gave 429
FreeUsageLimitError, alternating runs, in the same minutes;
- with magpie downloading Bun 1.4.2 itself: 200 on 4 of 4 calls. The
first call after the download timed out connecting (10s), on mica's
flaky network.
- mote:
- gofmt;
- go vet of netproxy and provider for darwin, linux and windows;
- go test -tags nogui -timeout 45m of netproxy, provider, plugin and
gateway: ok at base 31dcfcc33;
- netproxy and provider again at this head on origin/main a5b797d8d:
ok.
Not run: the full suite. mote and mica were each running another
session's full suite. Not tried: a user's paid Zen key; there is none
here, and the free tier's limit comes before the key either way.
This commit is contained in:
@@ -429,6 +429,7 @@ and `TestHistoricalWindowHoldsUsesEachWindowsOwnReading`.
|
||||
- A Copilot account is known by its GitHub login and host (`CopilotAccountName`, #1220): `mona` on github.com, `mona@acme.ghe.com` on an enterprise's GHE.com. That name is its `logins.json` user, its row in every list, its usage card and its per-account routing settings, and it is what `SwitchLogin`, `SetLoginOn` and `ForgetLogin` take, so one login on two hosts is two accounts, neither written over by the other nor dropped as the editors' own. One saved before on an enterprise's host under its login alone is read under its name with the host (`copilotSavedName`), keeping its id; the editors' own remembered so is renamed in place, still hidden if it was (`copilotRenamed`). Either rename takes the account's per-account settings in `providers.json` (proxy, models, cap, concurrency) from the bare login to the new name before the new name is written to `logins.json` (`renameSettled`): a setting the new name has already stays, and while `providers.json` can't be read or written the account stays saved under its old name, its settings with it. `magpie accounts switch|forget copilot` takes the full name, the login with `--host <name>.ghe.com`, or the login alone when it names one account.
|
||||
- A Codex account is known by its email, with the plan for a workspace seat (`codexUser`), and a second seat of one email in another workspace by that name with its workspace after it (`codexName`): `me@example.com · Team · ws-two`. The account Codex is signed in to goes by the name it is saved under (`codexLiveName`) everywhere: its provider's `Account.User` (`codexAccount`), `liveLogin`, and its session identity (`SessionIdentities`). Its allowance, rests and sticks (`restKey`), cap, proxy, model list, a gateway key's account list (`LoginID`) and the Routing page all go by that name, so two seats of one email are never read as one (#1424). One ChatGPT sign-in reaches every workspace of its login with one refresh token, and the Codex app's workspace switch rewrites only `account_id` in `auth.json`, so two saved workspaces can share the sign-in Codex holds. Such an account is renewed where Codex holds it (`heldByCodex`, `codexHeldIn`) but its requests, allowance, plan and resets name its own workspace (`codexOwnWorkspace`), and a sign-in sync carries Codex's sign-in only on the record of its workspace (`codexWorkspacesApart` in `liveCodex` and `applyLogins`). Before, the account not in use read the one in use's (JdAZzzzzz on X: a Team seat read as the personal Prolite with its resets; `TestCodexAppWorkspaceSwitchReadsEachWorkspace`).
|
||||
- Every request to the ChatGPT backend (`CodexBase`'s host) goes over HTTP/1.1, as Codex itself speaks to it: each transport [`netproxy.Dispatch`](../../internal/netproxy/netproxy.go) makes (`http.DefaultClient`'s, the gateway's) sends a request `netproxy.HTTP1` names through an HTTP/1.1 copy of itself whose TLS hello offers no h2, and the provider package sets `HTTP1` to `codexBackend` ([codex_http1.go](../../internal/provider/codex_http1.go)). That covers the gateway's turns, the models list, the warm-up, the allowance, its resets and spending one, through the proxy in force, an account's own included. Every other vendor is still offered HTTP/2, except a provider held to HTTP/1.1 (`HTTP1`, below), a host whose HTTP/2 broke on a TLS record error, and the requests of a download trying again after its transfer broke off (`netproxy.OverHTTP1`, `AgainOverHTTP1`, `BrokeOff`: magpie's update, from where it stopped, the masking model's files, Bun, Claude Code and the Grok CLI; biubiu8802 on X: a proxy cut every HTTP/2 stream of the update part way, "unexpected EOF", while it carried HTTP/1.1 whole; `TestDownloadBrokenOverHTTP2TriesHTTP1`, `TestAgainOverHTTP1`).
|
||||
- Every request to OpenCode Zen's free tier (an OpenCode host's `/inference/` paths, where `OpenCodeFreeURL` sends free models) goes out through the plugin host's fetch, which is Bun's, not Go's: each `netproxy.Dispatch` transport asks `netproxy.Elsewhere` first, and the provider package sets it to `zenFreeInBun` ([zen_bun.go](../../internal/provider/zen_bun.go)). Zen tells OpenCode from other clients by the connection: the bytes OpenCode 2.3.0 sent, sent again a minute apart, got 200 through Bun 1.4.2 and 1.4.4 and 429 `FreeUsageLimitError` ("Free models work in OpenCode") through Go's net/http and curl, with the public key or a user's own, since Zen checks a free model's limit before its key (biubiubiuzone on X). That covers the gateway's turns, the Test button and an OpenCode Go request asked again at Zen (`RetryOpenCodeFreeOnZen`). The host is told a provider no plugin claims (`magpie-opencode-free`), so no plugin's sign-in or fetch takes the request; a plugin's `chat.headers` hook still runs, as for every fetch. Where Bun can't be had (`plugin.HasBun` false after the fetch failed), the request goes through Go as before. Zen's paid paths (`/zen/v1`, `/zen/go/v1`) stay in Go (`TestZenFreeTierGoesThroughBun`, `TestZenPaidAndOthersStayInGo`, `TestZenFreeTierWithoutBun`).
|
||||
- A Codex Responses Lite request (an `additional_tools` input item, or `reasoning.context` `all_turns`; Codex 0.165 and on) carries its instructions in the input, and Codex sends it with no top-level `instructions` and no `reasoning.summary`. `codexBody` adds neither to it (`codexLite`): before, it added Codex's full instructions and `summary: "auto"`, about 4K input tokens a request more than the official client (legeling567 on X; `TestCodexBodyLiteGetsNoInstructions`). A request that isn't Lite still gets them. The backend's `x-codex-turn-state` stays with the account that issued it: the gateway keeps the state a reply gave for that account and turn (`client_metadata` `thread_id` and `turn_id`) and sends it on the turn's next request to the same account, as Codex over HTTP sends it back; a state Codex sends itself goes only to the account that issued it ([codex_turnstate.go](../../internal/gateway/codex_turnstate.go), `TestCodexPoolTurnStateStaysWithItsAccount`).
|
||||
- A streamed turn to the ChatGPT backend (POST `CodexBase`/responses with `"stream":true`) goes over the backend's WebSocket, as Codex's own client sends it, and comes back as the server-sent events the HTTP route answers with (`codexSocket` in [codex_socket.go](../../internal/gateway/codex_socket.go), first in the gateway's `upstreamTransport`, so Codex's own sign-in passed through and magpie's ChatGPT accounts both take it, through the proxy in force). On some networks a streamed HTTP reply from chatgpt.com is cut at about 120 s, before `response.completed`, while the WebSocket runs to the end (brickhao on Discord). The handshake carries the turn's headers with `OpenAI-Beta: responses_websockets=2026-02-06`, without `x-codex-turn-state` and the responses-lite header, which go in the message's `client_metadata` as Codex puts them; the message is the body with `"type":"response.create"` ahead of it (a zstd body is decoded first). `codex.rate_limits` and `codex.response.metadata`, read ahead of the reply, are also told as the `x-codex-*` and `x-codex-turn-state` headers the HTTP route carries; `responsesapi.websocket_timing` is dropped. An `error` frame ahead of the reply is that status with its error as the body; `websocket_connection_limit_reached`, a refused handshake or a body that isn't a streamed turn goes over HTTP instead, and a host that refused the handshake (other than 401, 429 or 5xx) is spoken HTTP for 10 minutes (`codexSocketShun`). A socket that ends, or won't take the message, before any frame of the reply was handed on (any close status, a dropped connection, a normal close with no reply) sends the same body over HTTP (`codexSocketEnded`): Lamrfu's long conversation was closed 1009 (message too big) by chatgpt.com and got a 502. A conversation's socket is kept between its turns, and a turn that carries on from the last goes on it as only its new input after `previous_response_id`, as Codex's own client sends it (`codexKept` in [codex_socket_keep.go](../../internal/gateway/codex_socket_keep.go); codex-rs `get_incremental_items`): rem_thank on X saw magpie send the whole conversation on a new socket every turn, which a long one meets as 1009. A socket is kept for a turn that names its conversation (`session-id` or `thread-id`, else `prompt_cache_key`) and ended `response.completed` with an id, keyed by the host, a digest of `Authorization` and `chatgpt-account-id`, the conversation's ids and the subagent headers (`codexKeepKey`), so another account's turn never finds it nor names its response; the next turn takes it out of the pool, so two turns at once each have a socket. It is let go after 10 minutes unused (`codexKeepIdle`), at 55 minutes from its handshake (`codexKeepAge`; the backend ends a connection at 60) and the oldest past 32 (`codexKeepMax`); the gateway's tests drain the pool in their cleanup (`codexKeepDrain`). The turn goes as a delta when every field but `input`, `client_metadata` and `stream_options` is as the last turn sent it, and its input begins with the last turn's input and then that turn's `response.output_item.done` items, each compared without its id, status, nulls, empty lists, annotations and logprobs (`codexSocketItem`); anything else goes whole on the kept socket. What is compared is the body as it goes, after masking and every translation, so a turn masked otherwise than the last goes whole. A kept socket that fails before the reply is handed on (closed while kept, the write fails, or an `error` frame first, such as `previous_response_not_found` or the connection limit) is closed and the turn goes whole on a new socket, and from there over HTTP as before (`errCodexSocketAgain`). A message at least as big as one a host closed 1009 goes to it over HTTP for 10 minutes (`codexTooBig`). A socket closed after the reply began reads as a cut stream (`io.ErrUnexpectedEOF`), and is not asked again. Codex speaks to magpie over its own WebSocket since #4058 ([A Responses WebSocket](gateway-routing.md#a-responses-websocket)), sending a turn as a delta after `previous_response_id`; magpie gives each turn the whole conversation before it goes on, and this leg cuts its own delta for the kept socket. A turn on the socket tells the try's client trace of itself as Go's client tells it of an HTTP request (`socketTrace`): on a kept socket it is a request on an open connection, on a new one the handshake's DNS, connect and TLS stand and its round trip is the wait for the connection; the message written is the request written and the first frame the reply's first byte. So the Routing page's "Where the time went" (`TryNet`) and the usage record's split have the vendor's wait for every socket turn, where a kept socket's turn had nothing but its masking and a new socket's put the backend's wait in its first token (buhaodeshiyehao on X, `TestSocketTurnTellsWhereItsTimeWent`). The gateway's tests turn it off in TestMain (`codexSocketOff`); codex_socket_test's fakes speak it.
|
||||
- A provider the user added may have its certificate left unchecked (`InsecureTLS`, the editor's Certificate row, #2383: a vLLM on the LAN, Ollama behind a self-signed cert, a company CA). Only one with a base URL of the user's own takes it (`TakesInsecureTLS`: no account, no preset, not Vertex, not a subscription's or plugin's id); `Save` refuses it on any other, and one written into providers.json by hand is ignored. `Provider.Via` then adds `netproxy.WithUncheckedTLS` with the hosts of its own base URLs (`UncheckedHosts`: Chat, Responses, Anthropic, Gemini, Decide), so every request made on its behalf through a `Dispatch` transport (the gateway's turns, count_tokens, models, test and detect, balance) skips the check for those hosts alone, on a transport kept apart for each (`route.unchecked`). A redirect or a models, balance or image URL on another host is checked, and `netproxy.With` drops the leave for a request made for another provider. An `https://` proxy would be dialled with the same TLS config, so its certificate would go unchecked too: such a request is refused (`ErrUncheckedOverHTTPSProxy`); an `http://` or `socks5://` proxy is taken. Backup, export and sync carry the field with the provider; an import link doesn't.
|
||||
|
||||
@@ -203,6 +203,13 @@ func forChoice(c string) (*url.URL, error) {
|
||||
// its transport.
|
||||
var HTTP1 func(u *url.URL) bool
|
||||
|
||||
// Elsewhere sends a request that Go's own TLS can't carry another way,
|
||||
// before a transport of Dispatch's dials it: ok false leaves the request
|
||||
// to the transport. internal/provider sets it for OpenCode Zen's free
|
||||
// tier, which answers a client that isn't Bun's 429 (zen_bun.go); nil
|
||||
// leaves every request to its transport.
|
||||
var Elsewhere func(req *http.Request) (res *http.Response, ok bool, err error)
|
||||
|
||||
// Dispatch is a RoundTripper sending a request through base, unless its
|
||||
// context names a provider's own proxy (With): then through a clone of
|
||||
// base kept for that proxy alone. Connections are so reused among the
|
||||
@@ -249,6 +256,11 @@ type route struct {
|
||||
}
|
||||
|
||||
func (d *dispatch) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
if f := Elsewhere; f != nil {
|
||||
if res, ok, err := f(req); ok {
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
if d.moved() {
|
||||
d.CloseIdleConnections()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/yetone/magpie/internal/netproxy"
|
||||
"github.com/yetone/magpie/internal/plugin"
|
||||
)
|
||||
|
||||
// OpenCode Zen's free tier serves OpenCode alone, and knows it by its
|
||||
// connection, not its request: the same bytes OpenCode 2.3.0 sent, sent
|
||||
// again from the same computer a minute apart, were answered 200 by Bun's
|
||||
// fetch (1.4.2, magpie's, and 1.4.4, OpenCode's own) and 429
|
||||
// FreeUsageLimitError ("Free usage limit reached. Free models work in
|
||||
// OpenCode") by Go's net/http and by curl, over HTTP/1.1 and HTTP/2, with
|
||||
// the public key or a user's (biubiubiuzone on X: "opencode zen 配置官方的key
|
||||
// 后无法使用deepseek等 free模型,key可以在opencode app中正常使用"). Zen's
|
||||
// limit for a free model is checked before its key is (zen/util/handler.ts:
|
||||
// rateLimiter before authenticate), so a key doesn't lift it. So a request
|
||||
// to the free tier's paths (OpenCodeFreeURL) goes out through the plugin
|
||||
// host's fetch, which is Bun's, from wherever it is sent: the gateway, the
|
||||
// Test button, an OpenCode Go request asked again at Zen.
|
||||
func init() { netproxy.Elsewhere = zenFreeInBun }
|
||||
|
||||
// bunFetch is the plugin host's fetch (a var for tests).
|
||||
var bunFetch = plugin.Fetch
|
||||
|
||||
// hasBun says Bun is on this computer (a var for tests).
|
||||
var hasBun = plugin.HasBun
|
||||
|
||||
// zenBunProvider is the provider the host is told the request is for: no
|
||||
// plugin's, so no plugin's sign-in or fetch takes it over.
|
||||
const zenBunProvider = "magpie-opencode-free"
|
||||
|
||||
// zenFreeTier says req goes to Zen's free tier: an OpenCode host's
|
||||
// /inference paths, where OpenCodeFreeURL sends its free models.
|
||||
func zenFreeTier(req *http.Request) bool {
|
||||
return req.URL != nil && openCodeHost(req.URL.Hostname()) && strings.HasPrefix(req.URL.Path, "/inference/")
|
||||
}
|
||||
|
||||
// zenFreeInBun sends a request to Zen's free tier through Bun's fetch.
|
||||
// Where Bun can't be had (the download failed, offline), the request goes
|
||||
// as before, through Go's own transport.
|
||||
func zenFreeInBun(req *http.Request) (*http.Response, bool, error) {
|
||||
if !zenFreeTier(req) {
|
||||
return nil, false, nil
|
||||
}
|
||||
var body []byte
|
||||
if req.Body != nil && req.Body != http.NoBody {
|
||||
b, err := io.ReadAll(req.Body)
|
||||
req.Body.Close()
|
||||
if err != nil {
|
||||
return nil, true, err
|
||||
}
|
||||
body = b
|
||||
}
|
||||
h := map[string]string{}
|
||||
for k, vs := range req.Header {
|
||||
if len(vs) > 0 {
|
||||
h[strings.ToLower(k)] = vs[0]
|
||||
}
|
||||
}
|
||||
res, err := bunFetch(req.Context(), plugin.FetchRequest{
|
||||
Provider: zenBunProvider, URL: req.URL.String(), Method: req.Method, Headers: h, Body: body,
|
||||
})
|
||||
if err != nil && !hasBun() {
|
||||
req.Body = io.NopCloser(bytes.NewReader(body))
|
||||
return nil, false, nil
|
||||
}
|
||||
if res != nil {
|
||||
res.Request = req
|
||||
}
|
||||
return res, true, err
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/netproxy"
|
||||
"github.com/yetone/magpie/internal/plugin"
|
||||
)
|
||||
|
||||
// zenBunCase is a transport of Dispatch's that dials nothing, and the
|
||||
// requests the plugin host's fetch was handed.
|
||||
func zenBunCase(t *testing.T, fetchErr error, bun bool) (*http.Client, *[]plugin.FetchRequest, *int) {
|
||||
t.Helper()
|
||||
var got []plugin.FetchRequest
|
||||
dials := 0
|
||||
was, wasBun := bunFetch, hasBun
|
||||
t.Cleanup(func() { bunFetch, hasBun = was, wasBun })
|
||||
bunFetch = func(_ context.Context, r plugin.FetchRequest) (*http.Response, error) {
|
||||
got = append(got, r)
|
||||
if fetchErr != nil {
|
||||
return nil, fetchErr
|
||||
}
|
||||
return &http.Response{StatusCode: 200, Header: http.Header{}, Body: io.NopCloser(strings.NewReader(`{"ok":true}`))}, nil
|
||||
}
|
||||
hasBun = func() bool { return bun }
|
||||
base := &http.Transport{DialContext: func(context.Context, string, string) (net.Conn, error) {
|
||||
dials++
|
||||
return nil, errors.New("dialed")
|
||||
}}
|
||||
return &http.Client{Transport: netproxy.Dispatch(base)}, &got, &dials
|
||||
}
|
||||
|
||||
// The reporter's case: a free model with the user's own key, asked at
|
||||
// Zen's free tier, goes out through Bun's fetch, with the request's
|
||||
// headers and body as they are, and is never dialed by Go.
|
||||
func TestZenFreeTierGoesThroughBun(t *testing.T) {
|
||||
c, got, dials := zenBunCase(t, nil, true)
|
||||
body := `{"model":"deepseek-v4.1-flash-free","messages":[{"role":"user","content":"hi"}]}`
|
||||
req, _ := http.NewRequest("POST", "https://opencode.ai/inference/openai/v1/chat/completions", strings.NewReader(body))
|
||||
req.Header.Set("Authorization", "Bearer sk-user-own")
|
||||
req.Header.Set("User-Agent", "opencode/latest/2.2.5/cli")
|
||||
req.Header.Set("x-opencode-session", "ses_1")
|
||||
res, err := c.Do(req)
|
||||
if err != nil {
|
||||
t.Fatalf("free tier: %v (dials %d)", err, *dials)
|
||||
}
|
||||
b, _ := io.ReadAll(res.Body)
|
||||
res.Body.Close()
|
||||
if res.StatusCode != 200 || string(b) != `{"ok":true}` {
|
||||
t.Fatalf("reply %d %s", res.StatusCode, b)
|
||||
}
|
||||
if *dials != 0 || len(*got) != 1 {
|
||||
t.Fatalf("dials %d, Bun fetches %d: want 0 and 1", *dials, len(*got))
|
||||
}
|
||||
r := (*got)[0]
|
||||
if r.URL != "https://opencode.ai/inference/openai/v1/chat/completions" || r.Method != "POST" || string(r.Body) != body {
|
||||
t.Fatalf("sent %s %s %s", r.Method, r.URL, r.Body)
|
||||
}
|
||||
if r.Headers["authorization"] != "Bearer sk-user-own" || r.Headers["user-agent"] != "opencode/latest/2.2.5/cli" || r.Headers["x-opencode-session"] != "ses_1" {
|
||||
t.Fatalf("headers %v", r.Headers)
|
||||
}
|
||||
if r.Provider != zenBunProvider || r.Account != "" {
|
||||
t.Fatalf("told the host provider %q account %q", r.Provider, r.Account)
|
||||
}
|
||||
}
|
||||
|
||||
// Everything else, Zen's paid paths and OpenCode Go included, goes
|
||||
// through Go's transport as before.
|
||||
func TestZenPaidAndOthersStayInGo(t *testing.T) {
|
||||
c, got, dials := zenBunCase(t, nil, true)
|
||||
for _, u := range []string{
|
||||
"https://opencode.ai/zen/v1/chat/completions",
|
||||
"https://opencode.ai/zen/go/v1/chat/completions",
|
||||
"https://opencode.ai/zen/v1/models",
|
||||
"https://api.example.test/inference/openai/v1/chat/completions",
|
||||
} {
|
||||
req, _ := http.NewRequest("POST", u, strings.NewReader("{}"))
|
||||
if _, err := c.Do(req); err == nil || !strings.Contains(err.Error(), "dialed") {
|
||||
t.Fatalf("%s: %v, want Go's own dial", u, err)
|
||||
}
|
||||
}
|
||||
if len(*got) != 0 || *dials != 4 {
|
||||
t.Fatalf("Bun fetches %d, dials %d: want 0 and 4", len(*got), *dials)
|
||||
}
|
||||
}
|
||||
|
||||
// Where Bun can't be had, the request still goes, through Go, body and
|
||||
// all; where it can, the host's error is the request's.
|
||||
func TestZenFreeTierWithoutBun(t *testing.T) {
|
||||
c, got, dials := zenBunCase(t, errors.New("downloading Bun 1.4.2 to run plugins: offline"), false)
|
||||
req, _ := http.NewRequest("POST", "https://opencode.ai/inference/openai/v1/chat/completions", strings.NewReader(`{"a":1}`))
|
||||
if _, err := c.Do(req); err == nil || !strings.Contains(err.Error(), "dialed") || *dials != 1 || len(*got) != 1 {
|
||||
t.Fatalf("no Bun: %v, dials %d, fetches %d", err, *dials, len(*got))
|
||||
}
|
||||
c, _, dials = zenBunCase(t, errors.New("ECONNRESET"), true)
|
||||
req, _ = http.NewRequest("POST", "https://opencode.ai/inference/openai/v1/chat/completions", strings.NewReader(`{"a":1}`))
|
||||
if _, err := c.Do(req); err == nil || !strings.Contains(err.Error(), "ECONNRESET") || *dials != 0 {
|
||||
t.Fatalf("Bun's error: %v, dials %d", err, *dials)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user