diff options
author | Leo Kettmeir <crowlkats@toaxl.com> | 2023-08-16 14:02:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-16 14:02:15 +0200 |
commit | 1b0e394d48324b5e8416f9a563eb2f35719f0906 (patch) | |
tree | e1f0533c04714ff9efe1da0f276264cd1c71403f /cli/tests | |
parent | 838140fb82e696fb131f5c62c51c7b6dea56f3ad (diff) |
fix: release ReadeableStream in fetch (#17365)
Fixes #16648
---------
Co-authored-by: Aapo Alasuutari <aapo.alasuutari@gmail.com>
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/unit/fetch_test.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts index 204a159a7..83386d2ee 100644 --- a/cli/tests/unit/fetch_test.ts +++ b/cli/tests/unit/fetch_test.ts @@ -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 }); |