From 2187c11e5d026733b4df1d675cfe5922302c8f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 23 Aug 2021 16:15:59 +0200 Subject: fix(ext/http): resource leak on HttpConn.close() (#11805) This commit adds tracking of resources that are related to "HttpConn" so they can be closed automatically when closing the connection. --- cli/tests/unit/http_test.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'cli') diff --git a/cli/tests/unit/http_test.ts b/cli/tests/unit/http_test.ts index f8de63383..0642a6d67 100644 --- a/cli/tests/unit/http_test.ts +++ b/cli/tests/unit/http_test.ts @@ -815,3 +815,27 @@ unitTest( } }, ); + +// https://github.com/denoland/deno/issues/11743 +unitTest( + { perms: { net: true } }, + async function httpServerDoesntLeakResources() { + const listener = Deno.listen({ port: 4505 }); + const [conn, clientConn] = await Promise.all([ + listener.accept(), + Deno.connect({ port: 4505 }), + ]); + const httpConn = Deno.serveHttp(conn); + + await Promise.all([ + httpConn.nextRequest(), + clientConn.write(new TextEncoder().encode( + `GET / HTTP/1.1\r\nHost: 127.0.0.1:4505\r\n\r\n`, + )), + ]); + + httpConn.close(); + listener.close(); + clientConn.close(); + }, +); -- cgit v1.2.3