diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2021-09-13 00:19:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-13 01:19:38 +0200 |
commit | 2cc1577d286814d941000fc4653f6e8d59b2e190 (patch) | |
tree | 38d872117be47710d3cfa150c2e6983ed0a63b07 /cli/tests/unit/fetch_test.ts | |
parent | 0520ae62dd2f4e61287315bbfcd548864d46da45 (diff) |
fix(ext/fetch): Properly cancel upload stream when aborting (#11966)
Co-authored-by: Luca Casonato <lucacasonato@yahoo.com>
Diffstat (limited to 'cli/tests/unit/fetch_test.ts')
-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 ed384dd4f..f11174df2 100644 --- a/cli/tests/unit/fetch_test.ts +++ b/cli/tests/unit/fetch_test.ts @@ -1291,3 +1291,30 @@ unitTest( client.close(); }, ); + +unitTest( + { perms: { net: true } }, + async function fetchAbortWhileUploadStreaming(): Promise<void> { + const abortController = new AbortController(); + try { + await fetch( + "http://localhost:5552/echo_server", + { + method: "POST", + body: new ReadableStream({ + pull(controller) { + abortController.abort(); + controller.enqueue(new Uint8Array([1, 2, 3, 4])); + }, + }), + signal: abortController.signal, + }, + ); + fail("Fetch didn't reject."); + } catch (error) { + assert(error instanceof DOMException); + assertEquals(error.name, "AbortError"); + assertEquals(error.message, "Ongoing fetch was aborted."); + } + }, +); |