ump45nose's TestClaudeToolCallbackOnANonLoopbackAddress was red on their
macOS with "curl: (56) Recv failure: Connection reset by peer". The run
hands Claude Code the proxy magpie gives it for Anthropic (by default the
system's: netproxy.EnvWith), with NO_PROXY of localhost, 127.0.0.1, ::1
and the system's exceptions. A gateway on a LAN or Tailscale address
(MAGPIE_ADDR, #1546) isn't in it, so the helper Claude Code starts, which
inherits that environment, sent its tool callback to the proxy. A proxy
that resets it or can't reach back left the call short of the run, and the
turn with the tool's results found no run waiting. The same path is real,
not only the test's: Go's http client takes *_PROXY for every host but
loopback, and the helper serves Claude, Cursor and Grok runs alike.
The helper's callback is always magpie on this computer, so its client
now uses no proxy at all. The test stand-ins of the helper (the takeback
and fork scripts' curl) call back with --noproxy '*' as it does.
Run:
- Reproduced the report: settings.Proxy on a local listener that resets
every connection, TestClaudeToolCallbackOnANonLoopbackAddress red with
the reporter's exact curl (56) reset; green after (temporary edit, not
kept).
- New TestCallbackGoesPastTheAgentsProxy runs the helper as its own
process with every *_PROXY on a resetting proxy, calling back to this
computer's non-loopback address. Red on the old helper ("read: connection
reset by peer"), green now.
- gofmt -l clean; go vet -tags nogui for darwin, linux and windows on
internal/claudebridge and internal/gateway.
- Full suite: go test -timeout 45m ./... at a61a6f954 + this change: 65
ok, internal/provider red in TestSecurityKeychainAnswers only (10.03s,
the 10s keychainWait on a fake `security` written with os.WriteFile;
fixed at its cause in the next commit). internal/claudebridge and
internal/gateway ok.
25 lines
553 B
Go
25 lines
553 B
Go
package claudebridge
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/testenv"
|
|
)
|
|
|
|
// helperEnv makes the test binary the helper itself, as an agent starts
|
|
// it: a process of its own, reading the environment it was handed.
|
|
const helperEnv = "CLAUDEBRIDGE_TEST_HELPER"
|
|
|
|
// The tests run in a home of their own, never the user's real files.
|
|
func TestMain(m *testing.M) {
|
|
if os.Getenv(helperEnv) != "" {
|
|
if err := RunMCP(nil); err != nil {
|
|
os.Stderr.WriteString(err.Error() + "\n")
|
|
os.Exit(1)
|
|
}
|
|
os.Exit(0)
|
|
}
|
|
testenv.Main(m)
|
|
}
|