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

This commit is contained in:
Julius Marminge authored and GitHub committed 2026-04-05 16:53:53 +00:00
1 parent 12347082ef
commit e0874b651d
2 files changed
+18 -6

No files matched your search

+9 -3
View File
@@ -3,8 +3,9 @@ import { Atom } from "effect/unstable/reactivity";
import { appAtomRegistry } from "./atomRegistry";
export const SLOW_RPC_ACK_THRESHOLD_MS = 2_500;
export const SLOW_RPC_ACK_THRESHOLD_MS = 15_000;
export const MAX_TRACKED_RPC_ACK_REQUESTS = 256;
let slowRpcAckThresholdMs = SLOW_RPC_ACK_THRESHOLD_MS;
export interface SlowRpcAckRequest {
readonly requestId: string;
@@ -56,12 +57,12 @@ export function trackRpcRequestSent(requestId: string, tag: string): void {
startedAt: new Date(startedAtMs).toISOString(),
startedAtMs,
tag,
thresholdMs: SLOW_RPC_ACK_THRESHOLD_MS,
thresholdMs: slowRpcAckThresholdMs,
};
const timeoutId = setTimeout(() => {
pendingRpcAckRequests.delete(requestId);
appendSlowRpcAckRequest(request);
}, SLOW_RPC_ACK_THRESHOLD_MS);
}, slowRpcAckThresholdMs);
pendingRpcAckRequests.set(requestId, {
request,
@@ -119,9 +120,14 @@ function evictOldestPendingRpcRequestIfNeeded(): void {
}
export function resetRequestLatencyStateForTests(): void {
slowRpcAckThresholdMs = SLOW_RPC_ACK_THRESHOLD_MS;
clearAllTrackedRpcRequests();
}
export function setSlowRpcAckThresholdMsForTests(thresholdMs: number): void {
slowRpcAckThresholdMs = thresholdMs;
}
export function useSlowRpcAckRequests(): ReadonlyArray<SlowRpcAckRequest> {
return useAtomValue(slowRpcAckRequestsAtom);
}
+9 -3
View File
@@ -5,7 +5,11 @@ import {
__resetClientTracingForTests,
configureClientTracing,
} from "./observability/clientTracing";
import { getSlowRpcAckRequests, resetRequestLatencyStateForTests } from "./rpc/requestLatencyState";
import {
getSlowRpcAckRequests,
resetRequestLatencyStateForTests,
setSlowRpcAckThresholdMsForTests,
} from "./rpc/requestLatencyState";
import {
getWsConnectionStatus,
getWsConnectionUiState,
@@ -292,6 +296,8 @@ describe("WsTransport", () => {
});
it("marks unary requests as slow until the first server ack arrives", async () => {
const slowAckThresholdMs = 25;
setSlowRpcAckThresholdMsForTests(slowAckThresholdMs);
const transport = new WsTransport("ws://localhost:3020");
const requestPromise = transport.request((client) =>
@@ -320,7 +326,7 @@ describe("WsTransport", () => {
tag: WS_METHODS.serverUpsertKeybinding,
},
]);
}, 5_000);
}, 1_000);
socket.serverMessage(
JSON.stringify({
@@ -343,7 +349,7 @@ describe("WsTransport", () => {
expect(getSlowRpcAckRequests()).toEqual([]);
await transport.dispose();
}, 10_000);
}, 5_000);
it("sends unary RPC requests and resolves successful exits", async () => {
const transport = new WsTransport("ws://localhost:3020");