Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(client-runtime): a dropped session no longer reads as a failed connection #18469

Mergedotavio(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/18469/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 79 additions and 4 deletions.

x
0 of 2 viewed, 2 left
69 additions and 0 deletionspackages/client-runtime/src/connection/supervisor.test.tsModified
View file
@@ -36,6 +36,7 @@
type SupervisorConnectionState,
} from "./model.ts";
import * as RpcSession from "../rpc/session.ts";
+import { presentConnectionState } from "./presentation.ts";
import * as EnvironmentSupervisor from "./supervisor.ts";
import * as ConnectionWakeups from "./wakeups.ts";
import { connectionRouteId, entryWithRoutes, isLearned, mergeLearnedRoutes } from "./routes.ts";
@@ -969,6 +970,73 @@
}).pipe(Effect.provide(TestClock.layer())),
​
+ it.effect("does not report a session lost while suspended as a failed connection", () =>
+ Effect.gen(function* () {
+ const allowReconnect = yield* Deferred.make<void>();
+ const harness = yield* makeHarness({
+ prepare: (attempt) =>
+ attempt === 2
+ ? Deferred.await(allowReconnect).pipe(Effect.as(PREPARED_CONNECTION))
+ : Effect.succeed(PREPARED_CONNECTION),
+ });
+ const supervisor = yield* EnvironmentSupervisor.make(TARGET_ENTRY, {
+ initiallyDesired: true,
+ }).pipe(Effect.provide(harness.dependencies));
+​
+ yield* awaitState(supervisor.state, (state) => state.phase === "connected");
+ // The OS killed the socket while the app was suspended; its close arrives
+ // before the app reports it is active again.
+ yield* harness.closeLatestSession();