summaryrefslogtreecommitdiff
path: root/cli/tests/unit/fetch_test.ts
diff options
context:
space:
mode:
authorMarcos Casagrande <marcoscvp90@gmail.com>2020-05-30 07:02:41 +0200
committerGitHub <noreply@github.com>2020-05-30 01:02:41 -0400
commita82f24e9a8d269d43e32af10ae9cb6fd9bf88d9f (patch)
treed23c613ca7e7ae4df663429ff54a6c321e2610fa /cli/tests/unit/fetch_test.ts
parent24e545d5bd2b679055e6c3b637119c57c8ad1243 (diff)
test to check that resource handle is closed after stream is cancelled (#5956)
Diffstat (limited to 'cli/tests/unit/fetch_test.ts')
-rw-r--r--cli/tests/unit/fetch_test.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts
index 2738eba5e..6dfb23390 100644
--- a/cli/tests/unit/fetch_test.ts
+++ b/cli/tests/unit/fetch_test.ts
@@ -702,3 +702,15 @@ unitTest(
assertEquals(total, data.length);
}
);
+
+unitTest(
+ { perms: { net: true } },
+ async function fetchResourceCloseAfterStreamCancel(): Promise<void> {
+ const res = await fetch("http://localhost:4545/cli/tests/fixture.json");
+ assert(res.body !== null);
+
+ // After ReadableStream.cancel is called, resource handle must be closed
+ // The test should not fail with: Test case is leaking resources
+ await res.body.cancel();
+ }
+);