@devries-cameron20 / t3code-1 / commits / f5ecca4480
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Clear tracked RPCs on reconnect (#2000)

Julius Marminge committed Apr 13, 2026 at 13:16 UTC f5ecca4480b5b399833cdeade4c4abce1b74cf4d
2 files changed +52
apps/web/src/rpc/wsTransport.test.ts
+50
@@ -417,6 +417,56 @@ describe("WsTransport", () => {
417 await transport.dispose();
418 }, 5_000);
419
420 + it("clears slow unary request tracking when the transport reconnects", async () => {
421 + const slowAckThresholdMs = 25;
422 + setSlowRpcAckThresholdMsForTests(slowAckThresholdMs);
423 + const transport = createTransport("ws://localhost:3020");
424 +
425 + const requestPromise = transport.request((client) =>
426 + client[WS_METHODS.serverUpsertKeybinding]({
427 + command: "terminal.toggle",
428 + key: "ctrl+k",
429 + }),
430 + );
431 +
432 + await waitFor(() => {
433 + expect(sockets).toHaveLength(1);
434 + });
435 +
436 + const firstSocket = getSocket();
437 + firstSocket.open();
438 +
439 + await waitFor(() => {
440 + expect(firstSocket.sent).toHaveLength(1);
441 + });
442 +
443 + const firstRequest = JSON.parse(firstSocket.sent[0] ?? "{}") as { id: string };
444 +
445 + await waitFor(() => {
446 + expect(getSlowRpcAckRequests()).toMatchObject([
447 + {
448 + requestId: firstRequest.id,
449 + tag: WS_METHODS.serverUpsertKeybinding,
450 + },
451 + ]);
452 + }, 1_000);
453 +
454 + void requestPromise.catch(() => undefined);
455 +
456 + await transport.reconnect();
457 +
458 + expect(getSlowRpcAckRequests()).toEqual([]);
459 +
460 + await waitFor(() => {
461 + expect(sockets).toHaveLength(2);
462 + });
463 +
464 + const secondSocket = getSocket();
465 + secondSocket.open();
466 +
467 + await transport.dispose();
468 + }, 5_000);
469 +
470 it("sends unary RPC requests and resolves successful exits", async () => {
471 const transport = createTransport("ws://localhost:3020");
472
apps/web/src/rpc/wsTransport.ts
+2
@@ -12,6 +12,7 @@ import {
12 import { RpcClient } from "effect/unstable/rpc";
13
14 import { ClientTracingLive } from "../observability/clientTracing";
15 +import { clearAllTrackedRpcRequests } from "./requestLatencyState";
16 import {
17 createWsRpcProtocolLayer,
18 makeWsRpcProtocolClient,
@@ -189,6 +190,7 @@ export class WsTransport {
190 throw new Error("Transport disposed");
191 }
192
193 + clearAllTrackedRpcRequests();
194 const previousSession = this.session;
195 this.session = this.createSession();
196 await this.closeSession(previousSession);