Skip to content

Commit 01bf240

Browse files
mincuaclaude
andcommitted
Raise RPC WebSocket ping interval to prevent reconnect loop on large workspaces
The Effect RPC client pinger (makePinger in effect's RpcClient) pings every 5s and tears down the WebSocket if the peer does not answer within that window. On a large workspace, opening a thread keeps the server event loop busy for ~10-15s (per-project VCS/git status, repository detection, and favicon resolution across every sidebar project), so the server misses the ping, the client drops the transport and reconnects, the reconnect restarts the same heavy load, the next ping is missed, and the connection loops indefinitely — the thread never opens. Raise the ping interval to 45s via the existing effect patch so the connection survives a busy-but-alive backend. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
1 parent 82a9bcc commit 01bf240

2 files changed

Lines changed: 125 additions & 137 deletions

File tree

‎patches/[email protected]‎

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/dist/unstable/ai/McpServer.js b/dist/unstable/ai/McpServer.js
2-
index 4819ff0..f5e0f60 100644
2+
index 38eb099d99026120a437701adc4b0fc5b1d0c714..fe29f3368f6d5e52034728ce789c73a318ccc453 100644
33
--- a/dist/unstable/ai/McpServer.js
44
+++ b/dist/unstable/ai/McpServer.js
55
@@ -235,6 +235,26 @@ export const run = /*#__PURE__*/Effect.fnUntraced(function* (options) {
@@ -30,7 +30,7 @@ index 4819ff0..f5e0f60 100644
3030
clientSessions
3131
}));
3232
diff --git a/dist/unstable/rpc/RpcClient.d.ts b/dist/unstable/rpc/RpcClient.d.ts
33-
index b0f61df..ead663e 100644
33+
index b0f61df34613dee99a6f6f1b446a282b2319f5ab..ead663e54cee98fd799a3f3f0761f3f00c6e8420 100644
3434
--- a/dist/unstable/rpc/RpcClient.d.ts
3535
+++ b/dist/unstable/rpc/RpcClient.d.ts
3636
@@ -2,6 +2,7 @@ import * as Cause from "../../Cause.ts";
@@ -82,15 +82,8 @@ index b0f61df..ead663e 100644
8282
}>;
8383
/**
8484
* Represents optional client protocol hooks that run when a transport connects
85-
@@ -279,4 +311,4 @@ declare const ConnectionHooks_base: Context.ServiceClass<ConnectionHooks, "effec
86-
export declare class ConnectionHooks extends ConnectionHooks_base {
87-
}
88-
export {};
89-
-//# sourceMappingURL=RpcClient.d.ts.map
90-
\ No newline at end of file
91-
+//# sourceMappingURL=RpcClient.d.ts.map
9285
diff --git a/dist/unstable/rpc/RpcClient.js b/dist/unstable/rpc/RpcClient.js
93-
index a3161eb..0cb81f3 100644
86+
index a3161ebd4a0ef74bea2c2f3a4ec95b6dd89ace8f..eff7e8811bd46d670e7e673cee964fd400e2e29b 100644
9487
--- a/dist/unstable/rpc/RpcClient.js
9588
+++ b/dist/unstable/rpc/RpcClient.js
9689
@@ -46,6 +46,7 @@ export const makeNoSerialization = /*#__PURE__*/Effect.fnUntraced(function* (gro
@@ -276,7 +269,7 @@ index a3161eb..0cb81f3 100644
276269
}).pipe(Effect.flatMap(() => Effect.fail(new Socket.SocketError({
277270
reason: new Socket.SocketCloseError({
278271
code: 1000
279-
@@ -664,20 +693,20 @@ export const makeProtocolSocket = options => Protocol.make(Effect.fnUntraced(fun
272+
@@ -664,21 +693,21 @@ export const makeProtocolSocket = options => Protocol.make(Effect.fnUntraced(fun
280273
};
281274
}));
282275
const defaultRetryPolicy = /*#__PURE__*/Schedule.exponential(500, 1.5).pipe(/*#__PURE__*/Schedule.either(/*#__PURE__*/Schedule.spaced(5000)));
@@ -297,10 +290,12 @@ index a3161eb..0cb81f3 100644
297290
if (!recievedPong) return latch.open;
298291
recievedPong = false;
299292
- return writePing;
293+
- }).pipe(Effect.delay("5 seconds"), Effect.ignore, Effect.forever, Effect.interruptible, Effect.forkScoped);
300294
+ return (hooks?.onPing ?? Effect.void).pipe(Effect.andThen(writePing));
301-
}).pipe(Effect.delay("5 seconds"), Effect.ignore, Effect.forever, Effect.interruptible, Effect.forkScoped);
295+
+ }).pipe(Effect.delay("45 seconds"), Effect.ignore, Effect.forever, Effect.interruptible, Effect.forkScoped);
302296
return {
303297
timeout: latch.await,
298+
reset,
304299
@@ -820,6 +849,11 @@ export const makeProtocolWorker = options => Protocol.make(Effect.fnUntraced(fun
305300
* @since 4.0.0
306301
*/
@@ -313,10 +308,3 @@ index a3161eb..0cb81f3 100644
313308
/**
314309
* Represents optional client protocol hooks that run when a transport connects
315310
* and disconnects.
316-
@@ -835,4 +869,4 @@ export const layerProtocolWorker = /*#__PURE__*/flow(makeProtocolWorker, /*#__PU
317-
export class ConnectionHooks extends /*#__PURE__*/Context.Service()("effect/rpc/RpcClient/ConnectionHooks") {}
318-
// internal
319-
const decodeDefect = /*#__PURE__*/Schema.decodeSync(/*#__PURE__*/Schema.Defect());
320-
-//# sourceMappingURL=RpcClient.js.map
321-
\ No newline at end of file
322-
+//# sourceMappingURL=RpcClient.js.map

0 commit comments

Comments
 (0)