Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(client-runtime): Reconnect works while the network reports offline #24932

Mergedonly21mil(GitHub profile, opens in a new tab)merged 6 commits intomain fromrefs/pull/24932/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 77 additions and 7 deletions.

x
0 of 2 viewed, 2 left
60 additions and 0 deletionspackages/client-runtime/src/connection/supervisor.test.tsModified
View file
@@ -361,6 +361,66 @@
}),
​
+ it.effect("explicit retry connects while the network still reports offline", () =>
+ Effect.gen(function* () {
+ const harness = yield* makeHarness({
+ networkStatus: "offline",
+ prepare: () => Effect.sleep("1 second").pipe(Effect.as(PREPARED_CONNECTION)),
+ });
+ const supervisor = yield* EnvironmentSupervisor.make(RELAY_ENTRY, {
+ initiallyDesired: true,
+ }).pipe(Effect.provide(harness.dependencies));
+​
+ yield* awaitState(supervisor.state, (state) => state.phase === "offline");
+ // The loop wakes on the earlier signal and takes the retry's flag while
+ // RetryRequested is still queued, so that signal must not cancel the attempt.
+ yield* supervisor.connect;
+ yield* supervisor.retryNow;
+ yield* TestClock.adjust("1 second");
+ const settled = yield* awaitState(
+ supervisor.state,
+ (state) => state.phase === "connected" || state.phase === "offline",
+ );
+​
+ expect(settled.phase).toBe("connected");
+ expect(yield* Ref.get(harness.prepareCount)).toBe(1);
+ expect(yield* Ref.get(harness.releaseCount)).toBe(0);
+ }),
+ );