diff options
author | Marvin Hagemeister <marvin@deno.com> | 2024-07-10 12:01:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-10 12:01:08 +0200 |
commit | 9a0d59d95df29202080cf40a6e0bda52ca7fa6a8 (patch) | |
tree | 4580f0bafae86c1b96ea7b655a8528b401494c25 /tests/unit_node/http_test.ts | |
parent | 2a86edf0afd65af3020c8e6ad84e26d5a687e535 (diff) |
fix(node/http): don't send destroyed requests (#24498)
Make sure that already destroyed requests are not actually sent.
This error was discovered in jsdom's test suite.
Diffstat (limited to 'tests/unit_node/http_test.ts')
-rw-r--r-- | tests/unit_node/http_test.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/unit_node/http_test.ts b/tests/unit_node/http_test.ts index 71043d985..9a37722c7 100644 --- a/tests/unit_node/http_test.ts +++ b/tests/unit_node/http_test.ts @@ -1003,6 +1003,24 @@ Deno.test( }, ); +Deno.test( + "[node/http] destroyed requests should not be sent", + async () => { + let receivedRequest = false; + const server = Deno.serve(() => { + receivedRequest = true; + return new Response(null); + }); + const request = http.request(`http://localhost:${server.addr.port}/`); + request.destroy(); + request.end("hello"); + + await new Promise((r) => setTimeout(r, 500)); + assertEquals(receivedRequest, false); + await server.shutdown(); + }, +); + Deno.test("[node/http] node:http exports globalAgent", async () => { const http = await import("node:http"); assert( |