From a82f24e9a8d269d43e32af10ae9cb6fd9bf88d9f Mon Sep 17 00:00:00 2001 From: Marcos Casagrande Date: Sat, 30 May 2020 07:02:41 +0200 Subject: [PATCH] test to check that resource handle is closed after stream is cancelled (#5956) --- cli/tests/unit/fetch_test.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts index 2738eba5ea..6dfb23390d 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 { + 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(); + } +);