Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): T3 Connect recovers within seconds after the host wakes from sleep #49601

Openvoltcrash(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/49601/headopened View on GitHub

Showing 2 changed files with 67 additions and 6 deletions.

x
0 of 2 viewed, 2 left
34 additions and 0 deletionsapps/server/src/cloud/ConnectReachability.test.tsModified
View file
@@ -3,6 +3,7 @@
import * as HostProcess from "@t3tools/shared/HostProcess";
import { SpawnExecutableResolution, type SpawnExecutableResolver } from "@t3tools/shared/shell";
import { describe, expect, it } from "@effect/vitest";
+import * as Clock from "effect/Clock";
import * as Duration from "effect/Duration";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
@@ -173,6 +174,39 @@
}).pipe(Effect.provide(layer));
}),
+​
+ it.effect("restarts a stale cloudflared soon after the host wakes from sleep", () =>
+ Effect.gen(function* () {
+ const restarts = yield* Queue.unbounded<number>();
+ const testClock = yield* TestClock.testClockWith(Effect.succeed);
+ // A suspend moves the wall clock without running timers.
+ let sleptMillis = 0;
+ const wallMillis = () => testClock.currentTimeMillisUnsafe() + sleptMillis;
+ const layer = reachabilityLayer(
+ Effect.succeed({ status: 530, body: { cloudflareError: 1033 } }),
+ (pid, stillDead) =>
+ stillDead.pipe(Effect.tap((dead) => (dead ? Queue.offer(restarts, pid) : Effect.void))),
+ ).pipe(
+ Layer.provide(
+ Layer.succeed(Clock.Clock, {
+ ...testClock,
+ currentTimeMillisUnsafe: wallMillis,