Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): allow slow backends to start before showing recovery #26247

Mergedshivamhwp(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/26247/headmerged by maria-rcks View on GitHub

Showing 2 changed files with 40 additions and 1 deletion.

x
0 of 2 viewed, 2 left
38 additions and 0 deletionsapps/desktop/src/backend/DesktopBackendManager.test.tsModified
View file
@@ -631,4 +631,42 @@
}).pipe(Effect.provide(TestClock.layer())),
+​
+ it.effect("waits out a slow startup and reports one that never becomes ready", () =>
+ Effect.scoped(
+ Effect.gen(function* () {
+ const reports = yield* Queue.unbounded<DesktopBackendManager.BackendStartupFailure>();
+ const startInstance = (status: Ref.Ref<number>, onReady?: Effect.Effect<void>) =>
+ makeTestInstance({
+ spawnerLayer: Layer.succeed(
+ ChildProcessSpawner.ChildProcessSpawner,
+ ChildProcessSpawner.make(() =>
+ Effect.succeed(makeProcess({ exitCode: Effect.never })),
+ ),
+ ),
+ httpClientLayer: layerHttpClient((request) =>
+ Ref.get(status).pipe(Effect.map((code) => responseForRequest(request, code))),
+ ),
+ onStartupFailure: (failure) => Queue.offer(reports, failure).pipe(Effect.asVoid),
+ ...(onReady ? { onReady } : {}),
+ }).pipe(Effect.tap((instance) => instance.start));
+​
+ const slowStatus = yield* Ref.make(503);
+ const ready = yield* Deferred.make<void>();
+ yield* startInstance(slowStatus, Deferred.succeed(ready, undefined).pipe(Effect.asVoid));
+ yield* TestClock.adjust(Duration.seconds(66));
+ yield* Ref.set(slowStatus, 200);
+ yield* TestClock.adjust(Duration.millis(100));