mirror of
https://github.com/coder/coder.git
synced 2026-09-22 05:05:20 +08:00
The AI Gateway tests reserved a port with `testutil.RandomPort`, which binds and closes `127.0.0.1:0`, then bound it later in `serve`. If something took the port in between, `serve` failed at `net.Listen` and the error went unread, leaving only a 10s `Eventually` timeout. The gateway now exposes its bound address via `httpAddr` and a `listenerReady` latch, so tests listen on port 0 and read the address afterwards. `requireListening` reports `serve`'s error where an address must still be fixed upfront. --- Investigated and authored with Coder Agents. --------- Co-authored-by: Cian Johnston <cian@coder.com>