The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 25, 06:15 UTC
Raise slow RPC ack warning threshold to 15s (#1760)
Julius Marminge committed
Apr 5, 2026 at 09:53 UTC
e0874b651d5c5fa5c578be932aada627b95c3f52
2 files changed
+18
-6
apps/web/src/rpc/requestLatencyState.ts
+9
-3
@@ -3,8 +3,9 @@ import { Atom } from "effect/unstable/reactivity";
3
4
import { appAtomRegistry } from "./atomRegistry";
5
6
-export const SLOW_RPC_ACK_THRESHOLD_MS = 2_500;
6
+export const SLOW_RPC_ACK_THRESHOLD_MS = 15_000;
7
export const MAX_TRACKED_RPC_ACK_REQUESTS = 256;
8
+let slowRpcAckThresholdMs = SLOW_RPC_ACK_THRESHOLD_MS;
9
10
export interface SlowRpcAckRequest {
11
readonly requestId: string;
@@ -56,12 +57,12 @@ export function trackRpcRequestSent(requestId: string, tag: string): void {
57
startedAt: new Date(startedAtMs).toISOString(),
58
startedAtMs,
59
tag,
59
- thresholdMs: SLOW_RPC_ACK_THRESHOLD_MS,
60
+ thresholdMs: slowRpcAckThresholdMs,
61
};
62
const timeoutId = setTimeout(() => {
63
pendingRpcAckRequests.delete(requestId);
64
appendSlowRpcAckRequest(request);
64
- }, SLOW_RPC_ACK_THRESHOLD_MS);
65
+ }, slowRpcAckThresholdMs);
66
67
pendingRpcAckRequests.set(requestId, {
68
request,
@@ -119,9 +120,14 @@ function evictOldestPendingRpcRequestIfNeeded(): void {
120
}
121
122
export function resetRequestLatencyStateForTests(): void {
123
+ slowRpcAckThresholdMs = SLOW_RPC_ACK_THRESHOLD_MS;
124
clearAllTrackedRpcRequests();
125
}
126
127
+export function setSlowRpcAckThresholdMsForTests(thresholdMs: number): void {
128
+ slowRpcAckThresholdMs = thresholdMs;
129
+}
130
+
131
export function useSlowRpcAckRequests(): ReadonlyArray<SlowRpcAckRequest> {
132
return useAtomValue(slowRpcAckRequestsAtom);
133
}
apps/web/src/wsTransport.test.ts
+9
-3
@@ -5,7 +5,11 @@ import {
5
__resetClientTracingForTests,
6
configureClientTracing,
7
} from "./observability/clientTracing";
8
-import { getSlowRpcAckRequests, resetRequestLatencyStateForTests } from "./rpc/requestLatencyState";
8
+import {
9
+ getSlowRpcAckRequests,
10
+ resetRequestLatencyStateForTests,
11
+ setSlowRpcAckThresholdMsForTests,
12
+} from "./rpc/requestLatencyState";
13
import {
14
getWsConnectionStatus,
15
getWsConnectionUiState,
@@ -292,6 +296,8 @@ describe("WsTransport", () => {
296
});
297
298
it("marks unary requests as slow until the first server ack arrives", async () => {
299
+ const slowAckThresholdMs = 25;
300
+ setSlowRpcAckThresholdMsForTests(slowAckThresholdMs);
301
const transport = new WsTransport("ws://localhost:3020");
302
303
const requestPromise = transport.request((client) =>
@@ -320,7 +326,7 @@ describe("WsTransport", () => {
326
tag: WS_METHODS.serverUpsertKeybinding,
327
},
328
]);
323
- }, 5_000);
329
+ }, 1_000);
330
331
socket.serverMessage(
332
JSON.stringify({
@@ -343,7 +349,7 @@ describe("WsTransport", () => {
349
expect(getSlowRpcAckRequests()).toEqual([]);
350
351
await transport.dispose();
346
- }, 10_000);
352
+ }, 5_000);
353
354
it("sends unary RPC requests and resolves successful exits", async () => {
355
const transport = new WsTransport("ws://localhost:3020");