diff options
author | Marcos Casagrande <marcoscvp90@gmail.com> | 2020-05-30 07:02:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-30 01:02:41 -0400 |
commit | a82f24e9a8d269d43e32af10ae9cb6fd9bf88d9f (patch) | |
tree | d23c613ca7e7ae4df663429ff54a6c321e2610fa /cli/tests/unit/fetch_test.ts | |
parent | 24e545d5bd2b679055e6c3b637119c57c8ad1243 (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.ts | 12 |
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(); + } +); |