Skip to content

Commit ad7b6c7

Browse files
test(client): reset-race test waits for the wakeup before finishing the check
The pending check could finish before the supervisor handled the network-change wakeup, so the test could pass without exercising the stale-result guard. It now waits for the post-wakeup session probe, which runs after the silent routes are forgotten. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 0a2ba7b commit ad7b6c7

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎packages/client-runtime/src/connection/supervisor.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,6 +1694,8 @@ describe("EnvironmentSupervisor routes", () => {
16941694
const lanChecks = yield* Ref.make(0);
16951695
const checkStarted = yield* Deferred.make<void>();
16961696
const finishCheck = yield* Deferred.make<void>();
1697+
const woke = yield* Ref.make(false);
1698+
const wakeupHandled = yield* Deferred.make<void>();
16971699
const harness = yield* makeHarness({
16981700
checkRoute: (route) =>
16991701
route.target._tag === "BearerConnectionTarget"
@@ -1711,6 +1713,14 @@ describe("EnvironmentSupervisor routes", () => {
17111713
)
17121714
: Effect.succeed("unchecked"),
17131715
prepare: (_attempt, target) => Effect.succeed(preparedFor(target)),
1716+
// The wakeup probes the session only after it forgets the silent routes.
1717+
probe: () =>
1718+
Ref.get(woke).pipe(
1719+
Effect.flatMap((afterWake) =>
1720+
afterWake ? Deferred.succeed(wakeupHandled, undefined) : Effect.void,
1721+
),
1722+
Effect.asVoid,
1723+
),
17141724
});
17151725
const supervisor = yield* EnvironmentSupervisor.make(LAN_THEN_RELAY_ENTRY, {
17161726
initiallyDesired: true,
@@ -1722,7 +1732,9 @@ describe("EnvironmentSupervisor routes", () => {
17221732
);
17231733
yield* TestClock.adjust("60 seconds");
17241734
yield* Deferred.await(checkStarted);
1735+
yield* Ref.set(woke, true);
17251736
yield* harness.wake("network-changed");
1737+
yield* Deferred.await(wakeupHandled);
17261738
yield* Deferred.succeed(finishCheck, undefined);
17271739

17281740
yield* awaitState(

0 commit comments

Comments
 (0)