Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
Clear tracked RPCs on reconnect (#2000)
Julius Marmingef5ecca4480b5
diff --git a/apps/web/src/rpc/wsTransport.test.ts b/apps/web/src/rpc/wsTransport.test.tsindex 12c3d4528..a5610a931 100644--- a/apps/web/src/rpc/wsTransport.test.ts+++ b/apps/web/src/rpc/wsTransport.test.ts@@ -417,6 +417,56 @@ describe("WsTransport", () => {await transport.dispose();}, 5_000);+ it("clears slow unary request tracking when the transport reconnects", async () => {+ const slowAckThresholdMs = 25;+ setSlowRpcAckThresholdMsForTests(slowAckThresholdMs);+ const transport = createTransport("ws://localhost:3020");++ const requestPromise = transport.request((client) =>+ client[WS_METHODS.serverUpsertKeybinding]({+ command: "terminal.toggle",+ key: "ctrl+k",+ }),+ );++ await waitFor(() => {+ expect(sockets).toHaveLength(1);+ });++ const firstSocket = getSocket();+ firstSocket.open();++ await waitFor(() => {+ expect(firstSocket.sent).toHaveLength(1);+ });++ const firstRequest = JSON.parse(firstSocket.sent[0] ?? "{}") as { id: string };++ await waitFor(() => {+ expect(getSlowRpcAckRequests()).toMatchObject([+ {+ requestId: firstRequest.id,+ tag: WS_METHODS.serverUpsertKeybinding,+ },+ ]);+ }, 1_000);++ void requestPromise.catch(() => undefined);++ await transport.reconnect();++ expect(getSlowRpcAckRequests()).toEqual([]);++ await waitFor(() => {+ expect(sockets).toHaveLength(2);+ });++ const secondSocket = getSocket();+ secondSocket.open();++ await transport.dispose();+ }, 5_000);+it("sends unary RPC requests and resolves successful exits", async () => {const transport = createTransport("ws://localhost:3020");diff --git a/apps/web/src/rpc/wsTransport.ts b/apps/web/src/rpc/wsTransport.tsindex 8c86625dc..d9a50a9fa 100644--- a/apps/web/src/rpc/wsTransport.ts+++ b/apps/web/src/rpc/wsTransport.ts@@ -12,6 +12,7 @@ import {import { RpcClient } from "effect/unstable/rpc";import { ClientTracingLive } from "../observability/clientTracing";+import { clearAllTrackedRpcRequests } from "./requestLatencyState";import {createWsRpcProtocolLayer,makeWsRpcProtocolClient,@@ -189,6 +190,7 @@ export class WsTransport {throw new Error("Transport disposed");}+ clearAllTrackedRpcRequests();const previousSession = this.session;this.session = this.createSession();await this.closeSession(previousSession);