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);