From de6e44794b7a95b6895a9aab907e01788820d18c Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Wed, 30 Jun 2021 18:05:58 +0200 Subject: fix: panic in request body streaming (#11191) --- cli/tests/unit/fetch_test.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'cli') diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts index cf7510ea2..46eceb50c 100644 --- a/cli/tests/unit/fetch_test.ts +++ b/cli/tests/unit/fetch_test.ts @@ -3,6 +3,7 @@ import { assert, assertEquals, assertThrowsAsync, + deferred, fail, unimplemented, unitTest, @@ -1195,3 +1196,24 @@ unitTest( assertEquals(response.headers.get("Host"), addr); }, ); + +unitTest( + { perms: { net: true } }, + async function fetchNoServerReadableStreamBody() { + const done = deferred(); + const body = new ReadableStream({ + start(controller) { + controller.enqueue(new Uint8Array([1])); + setTimeout(() => { + controller.enqueue(new Uint8Array([2])); + done.resolve(); + }, 1000); + }, + }); + const nonExistantHostname = "http://localhost:47582"; + await assertThrowsAsync(async () => { + await fetch(nonExistantHostname, { body, method: "POST" }); + }, TypeError); + await done; + }, +); -- cgit v1.2.3