test(ai): occupy 127.0.0.1 explicitly in the port-fallback blocker

Callback flows now bind 127.0.0.1 for localhost; macOS lets a
specific-address bind coexist with the blocker's 0.0.0.0 wildcard bind, so
the fallback path never triggered. Contest the same interface.
This commit is contained in:
can1357
2026-07-23 22:04:16 +02:00
parent 8a17eb1216
commit ffc4cec4e7
@@ -26,11 +26,13 @@ class TestCallbackFlow extends OAuthCallbackFlow {
/**
* Bind a real loopback port so the next `Bun.serve({ port })` against the
* same port fails with EADDRINUSE. Returns the bound port plus a `release`
* callback for teardown.
* same port fails with EADDRINUSE. Occupies `127.0.0.1` explicitly — the
* interface callback flows bind for `localhost` — because macOS lets a
* specific-address bind coexist with a wildcard one. Returns the bound port
* plus a `release` callback for teardown.
*/
function occupyLoopbackPort(): { port: number; release: () => void } {
const server = Bun.serve({ port: 0, fetch: () => new Response("blocker") });
const server = Bun.serve({ hostname: "127.0.0.1", port: 0, fetch: () => new Response("blocker") });
const port = server.port;
if (typeof port !== "number") {
server.stop(true);