Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(client-runtime): an offline connection still tries when the offline report is stale #39223

Opencybersader(GitHub profile, opens in a new tab)wants to merge 5 commits intomain fromrefs/pull/39223/headopened View on GitHub

Showing 2 changed files with 40 additions and 3 deletions.

x
0 of 2 viewed, 2 left
27 additions and 0 deletionspackages/client-runtime/src/connection/supervisor.test.tsModified
View file
@@ -432,6 +432,33 @@
}),
​
+ it.effect("still tries while the device keeps reporting offline", () =>
+ Effect.gen(function* () {
+ const harness = yield* makeHarness({
+ networkStatus: "offline",
+ prepare: (attempt) =>
+ attempt === 1 ? Effect.fail(transient()) : Effect.succeed(PREPARED_CONNECTION),
+ });
+ const supervisor = yield* EnvironmentSupervisor.make(RELAY_ENTRY, {
+ initiallyDesired: true,
+ }).pipe(Effect.provide(harness.dependencies));
+​
+ yield* awaitState(supervisor.state, (state) => state.phase === "offline");
+ expect(yield* Ref.get(harness.prepareCount)).toBe(0);
+ // A recheck that fails while still reported offline stays offline, not backoff.
+ yield* TestClock.adjust("30 seconds");
+ yield* awaitState(
+ supervisor.state,
+ (state) => state.phase === "offline" && state.attempt === 1 && state.lastFailure === null,
+ );
+ expect(yield* Ref.get(harness.prepareCount)).toBe(1);
+ // The report never changes, but the host becomes reachable.
+ yield* TestClock.adjust("30 seconds");
+ yield* awaitState(supervisor.state, (state) => state.phase === "connected");
+ expect(yield* Ref.get(harness.prepareCount)).toBe(2);
+ }),
+ );