mirror of
https://github.com/denoland/deno.git
synced 2024-12-24 08:09:08 -05:00
fix: release ReadeableStream in fetch (#17365)
Fixes #16648 --------- Co-authored-by: Aapo Alasuutari <aapo.alasuutari@gmail.com>
This commit is contained in:
parent
75ea2c1b20
commit
3dab9ead27
2 changed files with 28 additions and 0 deletions
|
@ -1951,6 +1951,33 @@ Deno.test(
|
|||
},
|
||||
);
|
||||
|
||||
Deno.test(
|
||||
{ permissions: { net: true } },
|
||||
async function fetchRequestBodyEmptyStream() {
|
||||
const body = new ReadableStream({
|
||||
start(controller) {
|
||||
controller.enqueue(new Uint8Array([]));
|
||||
controller.close();
|
||||
},
|
||||
});
|
||||
|
||||
await assertRejects(
|
||||
async () => {
|
||||
const controller = new AbortController();
|
||||
const promise = fetch("http://localhost:4545/echo_server", {
|
||||
body,
|
||||
method: "POST",
|
||||
signal: controller.signal,
|
||||
});
|
||||
controller.abort();
|
||||
await promise;
|
||||
},
|
||||
DOMException,
|
||||
"The signal has been aborted",
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Deno.test("Request with subarray TypedArray body", async () => {
|
||||
const body = new Uint8Array([1, 2, 3, 4, 5]).subarray(1);
|
||||
const req = new Request("https://example.com", { method: "POST", body });
|
||||
|
|
|
@ -268,6 +268,7 @@ async function mainFetch(req, recursive, terminator) {
|
|||
}
|
||||
}
|
||||
WeakMapPrototypeDelete(requestBodyReaders, req);
|
||||
reader.releaseLock();
|
||||
core.tryClose(requestBodyRid);
|
||||
})();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue