diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-08-18 13:48:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-18 13:48:18 +0200 |
commit | a48ec1d5637398fd4e023bdbb6cc00399bf47631 (patch) | |
tree | 1de36ae053a60faaafc1310b78e8510631965dca /cli/tests/unit_node/http_test.ts | |
parent | c77c836a238ce683b21c12f88cd1101b930ce042 (diff) |
fix(node/http): emit error when addr in use (#20200)
Closes https://github.com/denoland/deno/issues/20186
Diffstat (limited to 'cli/tests/unit_node/http_test.ts')
-rw-r--r-- | cli/tests/unit_node/http_test.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/cli/tests/unit_node/http_test.ts b/cli/tests/unit_node/http_test.ts index 706c672f1..9feee0272 100644 --- a/cli/tests/unit_node/http_test.ts +++ b/cli/tests/unit_node/http_test.ts @@ -751,3 +751,29 @@ Deno.test( assertEquals(body, "hello"); }, ); + +Deno.test("[node/http] server emits error if addr in use", async () => { + const promise = deferred<void>(); + const promise2 = deferred<Error>(); + + const server = http.createServer(); + server.listen(9001); + + const server2 = http.createServer(); + server2.on("error", (e) => { + promise2.resolve(e); + }); + server2.listen(9001); + + const err = await promise2; + server.close(() => promise.resolve()); + server2.close(); + await promise; + const expectedMsg = Deno.build.os === "windows" + ? "Only one usage of each socket address" + : "Address already in use"; + assert( + err.message.startsWith(expectedMsg), + `Wrong error: ${err.message}`, + ); +}); |