Repository navigation
fix(server): listing linked environments no longer waits out an asleep peer #28543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
02e1abf
ae322e0
64b3d2f
7e2cd09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,10 +2,13 @@ import { NodeHttpServer } from "@effect/platform-node"; | |
| import { type ExecutionEnvironmentDescriptor, OrchestratorMcpFailure } from "@t3tools/contracts"; | ||
| import { expect, it } from "@effect/vitest"; | ||
| import * as Context from "effect/Context"; | ||
| import * as Deferred from "effect/Deferred"; | ||
| import * as Duration from "effect/Duration"; | ||
| import * as Effect from "effect/Effect"; | ||
| import * as Exit from "effect/Exit"; | ||
| import * as Layer from "effect/Layer"; | ||
| import * as Option from "effect/Option"; | ||
| import * as Queue from "effect/Queue"; | ||
| import * as Ref from "effect/Ref"; | ||
| import * as Schema from "effect/Schema"; | ||
| import * as SqlClient from "effect/sql/SqlClient"; | ||
|
|
@@ -339,6 +342,40 @@ it.effect("never sends a link's token to an address that stops answering as that | |
| ).pipe(Effect.provide(NodeHttpServer.layerTest)), | ||
| ); | ||
|
|
||
| it.effect("lists a peer asleep at every address as unreachable within one probe budget", () => | ||
| Effect.scoped( | ||
| Effect.gen(function* () { | ||
| const b = yield* serveB(box); | ||
| // Another address of the same machine, asleep too. | ||
| const wake = yield* Deferred.make<void>(); | ||
| const elsewhere = yield* serveRaw(() => | ||
| Deferred.await(wake).pipe(Effect.as(HttpServerResponse.empty({ status: 503 }))), | ||
| ); | ||
| yield* Effect.addFinalizer(() => Deferred.succeed(wake, undefined)); | ||
| const a = yield* makeA(laptop); | ||
| const pairing = yield* b.auth.issuePairingCredential(); | ||
| yield* a.links.link({ | ||
| url: b.url, | ||
| alternateUrls: [elsewhere], | ||
| pairingCode: pairing.credential, | ||
| access: "auto", | ||
| }); | ||
|
|
||
| yield* Ref.set(b.asleep, true); | ||
| const listing = yield* a.links.list.pipe(Effect.forkScoped); | ||
| yield* Queue.take(b.unanswered); | ||
| yield* TestClock.adjust(Duration.seconds(3)); | ||
| yield* Effect.yieldNow; | ||
| const listed = listing.pollUnsafe(); | ||
|
Comment on lines
+370
to
+371
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| expect( | ||
| listed === undefined | ||
| ? "still waiting on the asleep peer" | ||
| : Exit.map(listed, (links) => links.map((link) => link.status)), | ||
| ).toEqual(Exit.succeed(["unreachable"])); | ||
| }), | ||
| ).pipe(Effect.provide(NodeHttpServer.layerTest)), | ||
| ); | ||
|
|
||
| it.effect("reads one stored link without asking the peer", () => | ||
| Effect.scoped( | ||
| Effect.gen(function* () { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cover a reachable alternate address.
This case only checks that two unanswered addresses become unreachable. Add a case where the first address stalls and the alternate answers as the linked peer. Assert that listing returns
reachablewithout advancing the clock. This catches a sequential probe with an overall timeout.As per coding guidelines, “Backend behavior changes ship with focused tests for that behavior.”
Source: Coding guidelines