fix(e2e): cancel RPC RTT probe bodies

This commit is contained in:
Vincent Koc
2026-06-19 07:21:40 +02:00
parent 5776b9b4e6
commit 32ee308f55
2 changed files with 43 additions and 0 deletions
+2
View File
@@ -130,6 +130,7 @@ function formatErrorMessage(error) {
async function readyzReportsReady(response, options = {}) {
if (!response.ok) {
void response.body?.cancel().catch(() => undefined);
return false;
}
try {
@@ -235,6 +236,7 @@ export async function waitForGatewayReady({
`http://127.0.0.1:${port}/healthz`,
probeTimeoutMs,
);
void probe.response.body?.cancel().catch(() => undefined);
probe.clearTimeout();
} catch {
// Liveness is diagnostic only; /readyz is the usable RPC readiness contract.
+41
View File
@@ -580,4 +580,45 @@ describe("scripts/measure-rpc-rtt.mjs", () => {
}),
);
});
it("cancels unconsumed readiness probe response bodies", async () => {
const child = new EventEmitter();
let readyzCanceled = false;
let healthzCanceled = false;
const fetchImpl = vi
.fn()
.mockResolvedValueOnce({
body: {
async cancel() {
readyzCanceled = true;
},
},
ok: false,
status: 503,
})
.mockResolvedValueOnce({
body: {
async cancel() {
healthzCanceled = true;
},
},
ok: true,
status: 200,
})
.mockResolvedValueOnce(jsonResponse({ failing: [], ready: true }));
await waitForGatewayReady({
child,
fetchImpl,
port: 12345,
probeTimeoutMs: 7,
readyTimeoutMs: 50,
sleepMs: 1,
stderrPath: "/no/such/stderr.log",
});
expect(fetchImpl).toHaveBeenCalledTimes(3);
expect(readyzCanceled).toBe(true);
expect(healthzCanceled).toBe(true);
});
});