Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

effect@4.0.2.patch

31 lines1.6 KB

1diff --git a/dist/rpc/RpcClient.d.ts b/dist/rpc/RpcClient.d.ts
2index ebfe86f..3ff235d 100644
3--- a/dist/rpc/RpcClient.d.ts
4+++ b/dist/rpc/RpcClient.d.ts
5@@ -320,6 +320,8 @@ export declare const layerProtocolWorker: (options: {
6 declare const ConnectionHooks_base: Context.ServiceClass<ConnectionHooks, "effect/rpc/RpcClient/ConnectionHooks", {
7 readonly onConnect: Effect.Effect<void>;
8 readonly onDisconnect: Effect.Effect<void>;
9+ /** Runs when the socket is dropped because the server stopped answering, before `onDisconnect`. */
10+ readonly onPingTimeout?: Effect.Effect<void> | undefined;
11 }>;
12 /**
13 * Represents optional client protocol hooks that run when a transport connects
14diff --git a/dist/rpc/RpcClient.js b/dist/rpc/RpcClient.js
15index f5b14ef..cccf0a4 100644
16--- a/dist/rpc/RpcClient.js
17+++ b/dist/rpc/RpcClient.js
18@@ -688,11 +688,11 @@ export const makeProtocolSocket = options => Protocol.make(Effect.fnUntraced(fun
19 yield* processData(frames[i]);
20 }
21 }
22- }).pipe(Effect.scoped, Effect.raceFirst(Effect.flatMap(pinger.timeout, () => Effect.fail(new Socket.SocketError({
23+ }).pipe(Effect.scoped, Effect.raceFirst(Effect.flatMap(pinger.timeout, () => (Option.isSome(hooks) && hooks.value.onPingTimeout ? hooks.value.onPingTimeout : Effect.void).pipe(Effect.andThen(Effect.fail(new Socket.SocketError({
24 reason: new Socket.SocketReadError({
25 cause: new Error("ping timeout")
26 })
27- })))));
28+ })))))));
29 }).pipe(Option.isSome(hooks) ? Effect.ensuring(hooks.value.onDisconnect) : identity, Effect.tapCause(cause => {
30 const error = Cause.findError(cause);
31 const hasError = Result.isSuccess(error);