mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 04:47:03 -06:00
fix(e2e): cancel RPC RTT probe bodies
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user