From b911a11b2bd50780e3f8d9a1caf7cb9ebd320aa4 Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Sat, 21 Nov 2026 08:23:07 -0800 Subject: [PATCH 1/3] 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); From 7e8022d732a0f5fd8dc416376551c12b645e9978 Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Mon, 23 Nov 2026 08:12:05 -0800 Subject: [PATCH 2/3] test(server): refused-address test dials a port no test worker can bind Co-Authored-By: Claude Opus 5.5 --- apps/server/src/peer/PeerLinks.test.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/server/src/peer/PeerLinks.test.ts b/apps/server/src/peer/PeerLinks.test.ts index 2b7b26cee8d28..d813e0bbf7407 100644 --- a/apps/server/src/peer/PeerLinks.test.ts +++ b/apps/server/src/peer/PeerLinks.test.ts @@ -859,15 +859,13 @@ 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* () { - // Listen first: the OS can hand a just-closed port to the next listener. + // A closed ephemeral port can be reused by any test worker; unprivileged code cannot bind port 2. + const closed = "http://127.0.0.1:2"; 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); From aa89ba94fd6f4e3ef7b21fa0c0d0b55b0c4db086 Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Mon, 23 Nov 2026 08:13:04 -0800 Subject: [PATCH 3/3] test(server): clarify why the refused-address test uses port 2 Co-Authored-By: Claude Opus 5.5 --- apps/server/src/peer/PeerLinks.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/server/src/peer/PeerLinks.test.ts b/apps/server/src/peer/PeerLinks.test.ts index d813e0bbf7407..3861fbb97b074 100644 --- a/apps/server/src/peer/PeerLinks.test.ts +++ b/apps/server/src/peer/PeerLinks.test.ts @@ -859,7 +859,7 @@ 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* () { - // A closed ephemeral port can be reused by any test worker; unprivileged code cannot bind port 2. + // Any test worker can reuse a closed ephemeral port; port 2 is privileged and outside that range. const closed = "http://127.0.0.1:2"; const notT3 = yield* serveRaw(() => Effect.succeed(