Files
magpie/internal
yetone c26b2992e8 gateway: a handed-off gateway waits for a connection still answering its request, not only new and idle ones (#3451)
68ab4c06d made the end of a handed-off gateway wait for idle kept-alive
connections, so their next request is answered here instead of cut by
Shutdown. Its test went red on main's ubuntu CI at 56602426d (run
40682193794): `"" unexpected EOF`. net/http notes a connection idle
only once the goroutine that wrote its reply returns from the write,
and the agent can read that reply and the end can begin first. Then the
wait saw the connection as neither new nor idle, Shutdown began, and
closed the connection as idle once net/http noted it, cutting the
agent's next request: the same #3451 cut, on a busy machine.

unreadConns now keeps a connection from StateActive until it is closed
or hijacked (kept), and the wait counts those too. A connection never
used again still ends the wait at unreadWait (5s), as before.

TestHandedOffGatewayAnswersAConnectionStillAnswering holds the gateway's
write of the chunked reply's end for a second (lagConn), and hands off
while it sits there, for both a handover and `make dev`.

Run at this tree (origin/main f835bd713 + this):
- Reproduced first: a 300ms sleep injected before note's StateIdle gave
  CI's error in the existing kept-alive test, both subtests; green with
  the fix under the same injection.
- The new test on the old handover.go: red, `"" unexpected EOF`, both
  subtests. A first version lagged the first write, which wasn't the
  reply's end, and passed on the old code; it now lags the end.
- mote: TestHandedOffGateway* -race -count=3 ok; go vet
  ./internal/gateway for darwin, GOOS=linux, GOOS=windows ok;
  go test ./internal/gateway ok (481s); ./internal/gui red only on
  TestMainWindowCorners/macOS_26_SDK, #3949 (mote's macOS 27).
- WSL magpie-desktop: TestHandedOffGateway* -count=3 ok.
- gofmt -l clean.
Not run: the full ./... suite; a real update restart under a busy agent.
2026-10-28 21:08:02 +08:00
..
…
…
…
…
…
…