From ffc4cec4e771ac6dbc14969265c659dd95e8d9db Mon Sep 17 00:00:00 2001 From: can1357 Date: Thu, 23 Jul 2026 22:04:16 +0200 Subject: [PATCH] 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. --- packages/ai/test/callback-server-port-fallback.test.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/ai/test/callback-server-port-fallback.test.ts b/packages/ai/test/callback-server-port-fallback.test.ts index 65bdd5282..bfa3cd8cd 100644 --- a/packages/ai/test/callback-server-port-fallback.test.ts +++ b/packages/ai/test/callback-server-port-fallback.test.ts @@ -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);