From b911a11b2bd50780e3f8d9a1caf7cb9ebd320aa4 Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Sat, 21 Nov 2026 08:23:07 -0800 Subject: [PATCH] test(server): PeerLinks refused-address test no longer reuses its closed port The test closed one server, then started another on port 0. The OS can hand the just-closed port to the new server, so the "nothing listening" address answered. Start the answering server first. Co-Authored-By: Claude Opus 5.5 --- apps/server/src/peer/PeerLinks.test.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/server/src/peer/PeerLinks.test.ts b/apps/server/src/peer/PeerLinks.test.ts index 0b1f4f716474c..eb85f00aaebad 100644 --- a/apps/server/src/peer/PeerLinks.test.ts +++ b/apps/server/src/peer/PeerLinks.test.ts @@ -845,14 +845,15 @@ it.effect("linking a picked machine that answers nowhere names it and links noth it.live("linking an address with nothing listening says so, unlike one that is not T3 Code", () => Effect.scoped( Effect.gen(function* () { - const closed = yield* Effect.scoped( - serveRaw(() => Effect.succeed(HttpServerResponse.empty({ status: 404 }))), - ); + // Listen first: the OS can hand a just-closed port to the next listener. const notT3 = yield* serveRaw(() => Effect.succeed( HttpServerResponse.text("

Not Found

", { status: 404, contentType: "text/html" }), ), ); + const closed = yield* Effect.scoped( + serveRaw(() => Effect.succeed(HttpServerResponse.empty({ status: 404 }))), + ); const a = yield* makeA(laptop); const linking = (url: string) => a.links.link({ url, pairingCode: "unused", access: "auto" }).pipe(Effect.flip);