Skip to content

Commit 27f2b65

Browse files
committed
Fix timeout silently succeeding in waitForHttpReadyEffect
Effect.timeoutOption returns Option.None on timeout (on the success channel), not a TimeoutError on the error channel. The previous code discarded the Option result, so a timeout was treated as success. Now we explicitly match the Option: None maps to BackendTimeoutError, Some maps to Effect.void. The now-unreachable TimeoutError catchTag is removed.
1 parent ac1b470 commit 27f2b65

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

apps/desktop/src/backendReadiness.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as Cause from "effect/Cause";
33
import * as Data from "effect/Data";
44
import * as Duration from "effect/Duration";
55
import * as Effect from "effect/Effect";
6+
import * as Option from "effect/Option";
67
import * as Predicate from "effect/Predicate";
78
import * as Schedule from "effect/Schedule";
89
import { HttpClient } from "effect/unstable/http";
@@ -60,9 +61,13 @@ export const waitForHttpReadyEffect = Effect.fn("waitForHttpReadyEffect")(functi
6061
yield* client.get(requestUrl).pipe(
6162
Effect.asVoid,
6263
Effect.timeoutOption(timeout),
64+
Effect.flatMap(
65+
Option.match({
66+
onNone: () => Effect.fail(new BackendTimeoutError({ url: baseUrl })),
67+
onSome: () => Effect.void,
68+
}),
69+
),
6370
Effect.catchTags({
64-
TimeoutError: () => Effect.fail(new BackendTimeoutError({ url: baseUrl })),
65-
// Maybe map this to different error kind?
6671
HttpClientError: () => Effect.fail(new BackendTimeoutError({ url: baseUrl })),
6772
}),
6873
);

0 commit comments

Comments
 (0)