Skip to content

Commit bc0c114

Browse files
committed
fix(desktop): use Effect.catchTags for readiness re-probe per convention
Addresses the Macroscope convention review on #5526: waitForHttpReady fails only with the known BackendReadinessTimeoutError tag, so recover it with Effect.catchTags (the surrounding convention) instead of branching the whole channel on Effect.result, and drop the now-unneeded Result import. The repeat-loop boolean comes from Effect.as on each branch.
1 parent b8b299b commit bc0c114

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

‎apps/desktop/src/backend/DesktopBackendManager.ts‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import * as FileSystem from "effect/FileSystem";
3333
import * as Option from "effect/Option";
3434
import * as PlatformError from "effect/PlatformError";
3535
import * as Ref from "effect/Ref";
36-
import * as Result from "effect/Result";
3736
import * as Schedule from "effect/Schedule";
3837
import * as Schema from "effect/Schema";
3938
import * as Semaphore from "effect/Semaphore";
@@ -572,22 +571,22 @@ export const runBackendProcess = Effect.fn("runBackendProcess")(function* (
572571
// on "Connecting to WSL…" forever even though the backend kept running
573572
// and became healthy. Each round gets a fresh budget, and the forked
574573
// loop is torn down with the run scope once the child exits.
575-
const probeReadiness = Effect.fn("desktop.backendProcess.probeReadiness")(function* () {
576-
const outcome = yield* waitForHttpReady({
574+
const probeReadiness = Effect.fn("desktop.backendProcess.probeReadiness")(() =>
575+
waitForHttpReady({
577576
executablePath: options.executablePath,
578577
entryPath: options.entryPath,
579578
cwd: options.cwd,
580579
httpBaseUrl: options.httpBaseUrl,
581580
timeout: options.readinessTimeout ?? DEFAULT_BACKEND_READINESS_TIMEOUT,
582-
}).pipe(Effect.result);
583-
584-
if (Result.isSuccess(outcome)) {
585-
yield* options.onReady?.() ?? Effect.void;
586-
return true;
587-
}
588-
yield* options.onReadinessFailure?.(outcome.failure) ?? Effect.void;
589-
return false;
590-
});
581+
}).pipe(
582+
Effect.flatMap(() => options.onReady?.() ?? Effect.void),
583+
Effect.as(true),
584+
Effect.catchTags({
585+
BackendReadinessTimeoutError: (error) =>
586+
(options.onReadinessFailure?.(error) ?? Effect.void).pipe(Effect.as(false)),
587+
}),
588+
),
589+
);
591590

592591
yield* probeReadiness().pipe(Effect.repeat({ while: (ready) => !ready }), Effect.forkScoped);
593592

0 commit comments

Comments
 (0)