Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): a backend busy right after startup no longer ends in a fatal HTTP 500 screen #34918

Mergedjuliusmarmingemerged 2 commits intomain fromrefs/pull/34918/headmerged by maria-rcks View on GitHub

Showing 2 changed files with 34 additions and 1 deletion.

x
0 of 2 viewed, 2 left
32 additions and 0 deletionsapps/desktop/src/backend/DesktopLocalEnvironmentAuth.test.tsModified
View file
@@ -1,11 +1,13 @@
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
import { assert, describe, it } from "@effect/vitest";
+import * as Clock from "effect/Clock";
import * as Deferred from "effect/Deferred";
import * as Duration from "effect/Duration";
import * as Effect from "effect/Effect";
import * as Fiber from "effect/Fiber";
import * as Layer from "effect/Layer";
import * as Ref from "effect/Ref";
+import * as Result from "effect/Result";
import * as HttpClient from "effect/http/HttpClient";
import * as HttpClientRequest from "effect/http/HttpClientRequest";
import * as HttpClientResponse from "effect/http/HttpClientResponse";
@@ -238,4 +240,34 @@
assert.strictEqual(yield* Ref.get(requestCount), 1);
}).pipe(Effect.provide(TestClock.layer())),
+​
+ it.effect("waits through a backend that stalls for 30 seconds after it is ready", () =>
+ Effect.gen(function* () {
+ const requestCount = yield* Ref.make(0);
+ const layerHttpClient = Layer.succeed(
+ HttpClient.HttpClient,
+ HttpClient.make((request) =>
+ Effect.gen(function* () {
+ yield* Ref.update(requestCount, (count) => count + 1);
+ const now = yield* Clock.currentTimeMillis;
+ return now < 30_000 ? yield* Effect.never : tokenResponse(request);
+ }),