diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2024-07-24 20:33:45 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-24 20:33:45 +0900 |
commit | 199a8ca4c5a8c5b2a060ef6a8912766a6a98d0b7 (patch) | |
tree | f285ddbf9fa59687d5d0bc3610152af41f887a30 /tests/unit_node/http_test.ts | |
parent | 29934d558c188fdc3406706da19921ca5a389383 (diff) |
fix(ext/node/net): emit `error` before `close` when connection is refused (#24656)
Diffstat (limited to 'tests/unit_node/http_test.ts')
-rw-r--r-- | tests/unit_node/http_test.ts | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/unit_node/http_test.ts b/tests/unit_node/http_test.ts index b9fe767e6..3831cac06 100644 --- a/tests/unit_node/http_test.ts +++ b/tests/unit_node/http_test.ts @@ -846,7 +846,10 @@ Deno.test( "[node/http] client upgrade", { permissions: { net: true } }, async () => { - const { promise, resolve } = Promise.withResolvers<void>(); + const { promise: serverClosed, resolve: resolveServer } = Promise + .withResolvers<void>(); + const { promise: socketClosed, resolve: resolveSocket } = Promise + .withResolvers<void>(); const server = http.createServer((req, res) => { // @ts-ignore: It exists on TLSSocket assert(!req.socket.encrypted); @@ -887,12 +890,16 @@ Deno.test( // @ts-ignore it's a socket for real serverSocket!.end(); server.close(() => { - resolve(); + resolveServer(); + }); + socket.on("close", () => { + resolveSocket(); }); }); }); - await promise; + await serverClosed; + await socketClosed; }, ); |