The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 23:30 UTC
fix(server): one dropped probe no longer lists a live linked peer as unreachable (#34208)
Julius Marminge committed
Nov 11, 2026 at 03:34 UTC
faa8ad681861430740c5adfc225540eaf3e46272
2 files changed
+39
apps/server/src/peer/PeerLinks.test.ts
+32
@@ -440,6 +440,38 @@ it.effect("cancelling a descriptor probe aborts its request and leaves later res
440
).pipe(Effect.provide(NodeHttpServer.layerTest)),
441
);
442
443
+it.live("one dropped descriptor request does not list a live peer as unreachable", () =>
444
+ Effect.scoped(
445
+ Effect.gen(function* () {
446
+ const dropNext = yield* Ref.make(false);
447
+ const dropOnce = HttpRouter.middleware(
448
+ (httpEffect) =>
449
+ Effect.gen(function* () {
450
+ const request = yield* HttpServerRequest.HttpServerRequest;
451
+ if (
452
+ request.url.startsWith("/.well-known/t3/environment") &&
453
+ (yield* Ref.getAndSet(dropNext, false))
454
+ ) {
455
+ return HttpServerResponse.empty({ status: 503 });
456
+ }
457
+ return yield* httpEffect;
458
+ }),
459
+ { global: true },
460
+ );
461
+ const b = yield* servePeer(
462
+ box,
463
+ Layer.merge(McpHttpServer.toolkitRegistration(ProbeToolkit, probeHandlers), dropOnce),
464
+ );
465
+ const a = yield* makeA(laptop);
466
+ const pairing = yield* b.auth.issuePairingCredential();
467
+ yield* a.links.link({ url: b.url, pairingCode: pairing.credential, access: "auto" });
468
+
469
+ yield* Ref.set(dropNext, true);
470
+ expect((yield* a.links.list).map((link) => link.status)).toEqual(["reachable"]);
471
+ }),
472
+ ).pipe(Effect.provide(NodeHttpServer.layerTest)),
473
+);
474
+
475
it.effect("reads one stored link without asking the peer", () =>
476
Effect.scoped(
477
Effect.gen(function* () {
apps/server/src/peer/PeerLinks.ts
+7
@@ -26,6 +26,7 @@ import * as Option from "effect/Option";
26
import * as Predicate from "effect/Predicate";
27
import * as Redacted from "effect/Redacted";
28
import * as Result from "effect/Result";
29
+import * as Schedule from "effect/Schedule";
30
import * as Schema from "effect/Schema";
31
import * as SqlClient from "effect/sql/SqlClient";
32
import * as FetchHttpClient from "effect/http/FetchHttpClient";
@@ -222,6 +223,12 @@ const make = Effect.gen(function* () {
223
const describe = (origin: string) =>
224
clientFor(origin).pipe(
225
Effect.flatMap((client) => client.metadata.descriptor()),
226
+ // A brief network drop must not list a live peer as down; the timeout still bounds both tries.
227
+ Effect.retry({
228
+ times: 1,
229
+ schedule: Schedule.spaced("1 second"),
230
+ while: (error) => certificateErrorCode(error) === undefined,
231
+ }),
232
Effect.timeout(probeTimeout(origin)),
233
Effect.asSome,
234
Effect.catch((error) => {