diff options
-rw-r--r-- | cli/tests/unit/fetch_test.ts | 27 | ||||
-rw-r--r-- | ext/fetch/26_fetch.js | 1 |
2 files changed, 28 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 }); diff --git a/ext/fetch/26_fetch.js b/ext/fetch/26_fetch.js index 6be63d077..311a197a8 100644 --- a/ext/fetch/26_fetch.js +++ b/ext/fetch/26_fetch.js @@ -268,6 +268,7 @@ async function mainFetch(req, recursive, terminator) { } } WeakMapPrototypeDelete(requestBodyReaders, req); + reader.releaseLock(); core.tryClose(requestBodyRid); })(); } |