Skip to content

Commit 5ebb9a0

Browse files
committed
fix(client-runtime): use tagged handoff recovery
1 parent 2f22eec commit 5ebb9a0

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎packages/client-runtime/src/state/runtime.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as Cause from "effect/Cause";
33
import * as Effect from "effect/Effect";
44
import * as Exit from "effect/Exit";
55
import * as Option from "effect/Option";
6-
import * as Schema from "effect/Schema";
76
import * as Stream from "effect/Stream";
87
import * as SubscriptionRef from "effect/SubscriptionRef";
98
import { AsyncResult, Atom, AtomRegistry } from "effect/unstable/reactivity";
@@ -22,7 +21,13 @@ import {
2221
} from "../rpc/client.ts";
2322
import { EnvironmentSupervisor } from "../connection/supervisor.ts";
2423

25-
const isEnvironmentRpcUnavailableError = Schema.is(EnvironmentRpcUnavailableError);
24+
// `catchTags` preserves unmatched errors at runtime; this signature keeps that
25+
// generic remainder while removing the one known connection-handoff error.
26+
const waitForEnvironmentConnectionSignal = Effect.catchTags({
27+
EnvironmentRpcUnavailableError: () => Effect.never,
28+
}) as <A, E, R>(
29+
effect: Effect.Effect<A, E | EnvironmentRpcUnavailableError, R>,
30+
) => Effect.Effect<A, E, R>;
2631

2732
interface EnvironmentAtomOptions<Input, A, E, R> {
2833
readonly label: string;
@@ -550,7 +555,7 @@ export function createEnvironmentQueryAtomFamily<R, ER, Input, A, E>(
550555
// first, keep it pending until the signal selects the
551556
// reconnecting or terminal branch instead of flashing a
552557
// transient unavailable failure.
553-
Effect.catchIf(isEnvironmentRpcUnavailableError, () => Effect.never),
558+
waitForEnvironmentConnectionSignal,
554559
)
555560
: Effect.never;
556561
case "connecting":

0 commit comments

Comments
 (0)