diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2021-04-15 18:48:56 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-15 18:48:56 -0400 |
commit | fe9cee620a4c0d8923bdf99882f95275b69abcb4 (patch) | |
tree | 9b9e68fc3a837f05f4933195590cbcc1cb90462d /cli/tests/unit | |
parent | ad7f6d4510afc71ed40da1aa1ad649d59d3aef12 (diff) |
fix(#10182): hang during http server response (#10197)
Diffstat (limited to 'cli/tests/unit')
-rw-r--r-- | cli/tests/unit/http_test.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/cli/tests/unit/http_test.ts b/cli/tests/unit/http_test.ts index f7ea3a75a..6383afd42 100644 --- a/cli/tests/unit/http_test.ts +++ b/cli/tests/unit/http_test.ts @@ -200,3 +200,30 @@ unitTest( client.close(); }, ); + +unitTest( + { perms: { net: true } }, + async function httpServerRegressionHang() { + const promise = (async () => { + const listener = Deno.listen({ port: 4501 }); + const conn = await listener.accept(); + const httpConn = Deno.serveHttp(conn); + const event = await httpConn.nextRequest(); + assert(event); + const { request, respondWith } = event; + const reqBody = await request.text(); + assertEquals("request", reqBody); + await respondWith(new Response("response")); + httpConn.close(); + listener.close(); + })(); + + const resp = await fetch("http://127.0.0.1:4501/", { + method: "POST", + body: "request", + }); + const respBody = await resp.text(); + assertEquals("response", respBody); + await promise; + }, +); |