The plugin host gives Bun an HTTP bridge to a SOCKS proxy, listening on
127.0.0.1:0. A port just let go can be handed out again at once, so a
bridge to a SOCKS proxy on loopback that is down could be given that very
port. It then dialled itself, and bridgeConn read the SOCKS greeting as an
HTTP request under its one-minute deadline: every request through it hung
60s instead of failing at once. That is TestPluginSOCKSProxy's 60s timeouts
on ubuntu CI (closedPort frees a port, then the bridge listens), rerun as
load before. A user whose local SOCKS proxy is down could meet it too.
Bridge now listens again while still holding such a port (up to 3 times),
then lets the first go.
Run:
- Injected the reuse (listenLoopback handing out closedPort's port): before
the fix internal/plugin's SOCKS test failed after 60.03s with "context
deadline exceeded"; with it, the package passed in 2.4s.
- New TestBridgeNeverCarriesToItself (addr and localhost:<port>): red with
the loop taken out by hand, green with it.
- go test -race -count=20 -run TestBridge ./internal/netproxy: ok.
- go vet darwin, GOOS=linux -tags nogui, GOOS=windows: clean. gofmt -l clean.
- go test -tags nogui -count=1 -p 4 -timeout 45m ./... at d0ccbbebc + this:
58 ok; internal/gateway red only in TestMaxRPMCountsRetriesAndCounts
("a count with no room: 200 after 2.72s"), the open #1791 under load.
Not tried: the Windows box.