authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-04-05 09:53:53-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-04-05 16:53:53+00:00
loge0874b651d5c5fa5c578be932aada627b95c3f52
tree794069696e25f8753ad79daf22cbf14c4275ac95
parent12347082ef1c4bce3d4a96e4072b7ada9a5a5b29
signature Signed by PGP key B5690EEEBB952194

Raise slow RPC ack warning threshold to 15s (#1760)


2 files changed, 18 insertions(+), 6 deletions(-)

apps/web/src/rpc/requestLatencyState.ts+9-3
......@@ -3,8 +3,9 @@ import { Atom } from "effect/unstable/reactivity";
33
44import { appAtomRegistry } from "./atomRegistry";
55
6export const SLOW_RPC_ACK_THRESHOLD_MS = 2_500;
6export const SLOW_RPC_ACK_THRESHOLD_MS = 15_000;
77export const MAX_TRACKED_RPC_ACK_REQUESTS = 256;
8let slowRpcAckThresholdMs = SLOW_RPC_ACK_THRESHOLD_MS;
89
910export interface SlowRpcAckRequest {
1011 readonly requestId: string;
......@@ -56,12 +57,12 @@ export function trackRpcRequestSent(requestId: string, tag: string): void {
5657 startedAt: new Date(startedAtMs).toISOString(),
5758 startedAtMs,
5859 tag,
59 thresholdMs: SLOW_RPC_ACK_THRESHOLD_MS,
60 thresholdMs: slowRpcAckThresholdMs,
6061 };
6162 const timeoutId = setTimeout(() => {
6263 pendingRpcAckRequests.delete(requestId);
6364 appendSlowRpcAckRequest(request);
64 }, SLOW_RPC_ACK_THRESHOLD_MS);
65 }, slowRpcAckThresholdMs);
6566
6667 pendingRpcAckRequests.set(requestId, {
6768 request,
......@@ -119,9 +120,14 @@ function evictOldestPendingRpcRequestIfNeeded(): void {
119120}
120121
121122export function resetRequestLatencyStateForTests(): void {
123 slowRpcAckThresholdMs = SLOW_RPC_ACK_THRESHOLD_MS;
122124 clearAllTrackedRpcRequests();
123125}
124126
127export function setSlowRpcAckThresholdMsForTests(thresholdMs: number): void {
128 slowRpcAckThresholdMs = thresholdMs;
129}
130
125131export function useSlowRpcAckRequests(): ReadonlyArray<SlowRpcAckRequest> {
126132 return useAtomValue(slowRpcAckRequestsAtom);
127133}
apps/web/src/wsTransport.test.ts+9-3
......@@ -5,7 +5,11 @@ import {
55 __resetClientTracingForTests,
66 configureClientTracing,
77} from "./observability/clientTracing";
8import { getSlowRpcAckRequests, resetRequestLatencyStateForTests } from "./rpc/requestLatencyState";
8import {
9 getSlowRpcAckRequests,
10 resetRequestLatencyStateForTests,
11 setSlowRpcAckThresholdMsForTests,
12} from "./rpc/requestLatencyState";
913import {
1014 getWsConnectionStatus,
1115 getWsConnectionUiState,
......@@ -292,6 +296,8 @@ describe("WsTransport", () => {
292296 });
293297
294298 it("marks unary requests as slow until the first server ack arrives", async () => {
299 const slowAckThresholdMs = 25;
300 setSlowRpcAckThresholdMsForTests(slowAckThresholdMs);
295301 const transport = new WsTransport("ws://localhost:3020");
296302
297303 const requestPromise = transport.request((client) =>
......@@ -320,7 +326,7 @@ describe("WsTransport", () => {
320326 tag: WS_METHODS.serverUpsertKeybinding,
321327 },
322328 ]);
323 }, 5_000);
329 }, 1_000);
324330
325331 socket.serverMessage(
326332 JSON.stringify({
......@@ -343,7 +349,7 @@ describe("WsTransport", () => {
343349 expect(getSlowRpcAckRequests()).toEqual([]);
344350
345351 await transport.dispose();
346 }, 10_000);
352 }, 5_000);
347353
348354 it("sends unary RPC requests and resolves successful exits", async () => {
349355 const transport = new WsTransport("ws://localhost:3020");