Clear tracked RPCs on reconnect (#2000)
This commit is contained in:
1 parent
cadd708646
commit
f5ecca4480
2 files changed
+52
No files matched your search
@@ -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");
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user