TypeScript
fix(web): VCS status refresh no longer trips the slow-request toast (#22159)
Theo Browne069e63b11758
diff --git a/apps/web/src/rpc/requestLatencyState.test.ts b/apps/web/src/rpc/requestLatencyState.test.tsindex 822980de80b..fb9ff5c7f1b 100644--- a/apps/web/src/rpc/requestLatencyState.test.ts+++ b/apps/web/src/rpc/requestLatencyState.test.ts@@ -80,20 +80,23 @@ describe("requestLatencyState", () => {expect(getSlowRpcAckRequests()).toEqual([]);});- it("gives provider updates a longer threshold before warning", () => {- trackRpcRequestSent("1", WS_METHODS.serverUpdateProvider, "server.updateProvider · env-1");- vi.advanceTimersByTime(LONG_RUNNING_RPC_ACK_THRESHOLD_MS - 1);- expect(getSlowRpcAckRequests()).toEqual([]);+ it.each([WS_METHODS.serverUpdateProvider, WS_METHODS.vcsRefreshStatus])(+ "gives %s a longer threshold before warning",+ (method) => {+ trackRpcRequestSent("1", method, `${method} · env-1`);+ vi.advanceTimersByTime(LONG_RUNNING_RPC_ACK_THRESHOLD_MS - 1);+ expect(getSlowRpcAckRequests()).toEqual([]);- vi.advanceTimersByTime(1);- expect(getSlowRpcAckRequests()).toMatchObject([- {- requestId: "1",- tag: "server.updateProvider · env-1",- thresholdMs: LONG_RUNNING_RPC_ACK_THRESHOLD_MS,- },- ]);- });+ vi.advanceTimersByTime(1);+ expect(getSlowRpcAckRequests()).toMatchObject([+ {+ requestId: "1",+ tag: `${method} · env-1`,+ thresholdMs: LONG_RUNNING_RPC_ACK_THRESHOLD_MS,+ },+ ]);+ },+ );it("evicts the oldest pending requests once the tracker reaches capacity", () => {for (let index = 0; index < MAX_TRACKED_RPC_ACK_REQUESTS + 1; index += 1) {diff --git a/apps/web/src/rpc/requestLatencyState.ts b/apps/web/src/rpc/requestLatencyState.tsindex 75a8762979e..086e1dcda0d 100644--- a/apps/web/src/rpc/requestLatencyState.ts+++ b/apps/web/src/rpc/requestLatencyState.ts@@ -6,9 +6,11 @@ import { appAtomRegistry } from "./atomRegistry";export const SLOW_RPC_ACK_THRESHOLD_MS = 15_000;/**- * Some requests are slow by design — they shell out to a package manager on the- * server and only respond once the install finishes. Warning about those after- * 15s is noise, so they get a much longer leash.+ * Some requests are slow by design. Provider and server updates shell out to a+ * package manager and only respond once the install finishes. A VCS status+ * refresh fetches, may auto-pull, looks up the pull request, and first waits for+ * any background refresh of the same repository, which often totals over 15s.+ * Warning about those after 15s is noise, so they get a much longer leash.*/export const LONG_RUNNING_RPC_ACK_THRESHOLD_MS = 120_000;export const MAX_TRACKED_RPC_ACK_REQUESTS = 256;@@ -33,6 +35,7 @@ const longRunningRpcAckMethods = new Set<string>([WS_METHODS.serverUpdateProvider,WS_METHODS.serverRefreshProviders,WS_METHODS.serverUpdateServer,+ WS_METHODS.vcsRefreshStatus,]);const slowRpcAckRequestsAtom = Atom.make<ReadonlyArray<SlowRpcAckRequest>>([]).pipe(