fix(tooling): cancel oversized audit responses

This commit is contained in:
Vincent Koc
2026-06-03 12:00:52 +02:00
parent c68938c19e
commit 44fea3c94a
3 changed files with 13 additions and 1 deletions

View File

@@ -729,6 +729,7 @@ async function withBulkAdvisoryTimeout({ label, timeoutMs, run }) {
async function readBoundedResponseText(response, maxBytes, label) {
const contentLength = Number.parseInt(response.headers?.get?.("content-length") ?? "", 10);
if (Number.isFinite(contentLength) && contentLength > maxBytes) {
await response.body?.cancel().catch(() => undefined);
throw Object.assign(new Error(`${label} exceeded ${maxBytes} bytes`), { code: "ETOOBIG" });
}