summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2021-08-23 16:15:59 +0200
committerGitHub <noreply@github.com>2021-08-23 16:15:59 +0200
commit2187c11e5d026733b4df1d675cfe5922302c8f4b (patch)
tree09df93880f4dfb1c1ad2f60e89d5e6a0df7321b9 /cli
parent2c17045aa8fd6f01b379fbb6e5d29b9df45b9b1b (diff)
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.
Diffstat (limited to 'cli')
-rw-r--r--cli/tests/unit/http_test.ts24
1 files changed, 24 insertions, 0 deletions
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();
+ },
+);