From 84e1d84bb67d0020d63d18f4ebe1825a7a09344d Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Fri, 18 Oct 2024 20:48:09 +0900 Subject: [PATCH] workaround ipv4 vs ipv6 issues for windows by specifying ip address instead of localhost in problematic situation --- tests/unit_node/http_test.ts | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/unit_node/http_test.ts b/tests/unit_node/http_test.ts index 5736aad271..ec2c5807c6 100644 --- a/tests/unit_node/http_test.ts +++ b/tests/unit_node/http_test.ts @@ -460,7 +460,8 @@ Deno.test("[node/http] send request with non-chunked body", async () => { let requestHeaders: Headers; let requestBody = ""; - const hostname = "localhost"; + // TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net + const hostname = "127.0.0.1"; const port = 4505; const handler = async (req: Request) => { @@ -517,7 +518,8 @@ Deno.test("[node/http] send request with chunked body", async () => { let requestHeaders: Headers; let requestBody = ""; - const hostname = "localhost"; + // TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net + const hostname = "127.0.0.1"; const port = 4505; const handler = async (req: Request) => { @@ -564,7 +566,8 @@ Deno.test("[node/http] send request with chunked body as default", async () => { let requestHeaders: Headers; let requestBody = ""; - const hostname = "localhost"; + // TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net + const hostname = "127.0.0.1"; const port = 4505; const handler = async (req: Request) => { @@ -670,6 +673,7 @@ Deno.test("[node/http] ClientRequest handle non-string headers", async () => { // deno-lint-ignore no-explicit-any let headers: any; const { promise, resolve, reject } = Promise.withResolvers(); + // TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net const req = http.request("http://127.0.0.1:4545/echo_server", { method: "POST", headers: { 1: 2 }, @@ -713,6 +717,7 @@ Deno.test("[node/http] ClientRequest setTimeout", async () => { let body = ""; const { promise, resolve, reject } = Promise.withResolvers(); const timer = setTimeout(() => reject("timed out"), 50000); + // TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net const req = http.request("http://127.0.0.1:4545/http_version", (resp) => { resp.on("data", (chunk) => { body += chunk; @@ -734,6 +739,7 @@ Deno.test("[node/http] ClientRequest setNoDelay", async () => { let body = ""; const { promise, resolve, reject } = Promise.withResolvers(); const timer = setTimeout(() => reject("timed out"), 50000); + // TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net const req = http.request("http://127.0.0.1:4545/http_version", (resp) => { resp.on("data", (chunk) => { body += chunk; @@ -754,6 +760,7 @@ Deno.test("[node/http] ClientRequest setNoDelay", async () => { Deno.test("[node/http] ClientRequest PATCH", async () => { let body = ""; const { promise, resolve, reject } = Promise.withResolvers(); + // TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net const req = http.request("http://127.0.0.1:4545/echo_server", { method: "PATCH", }, (resp) => { @@ -776,6 +783,7 @@ Deno.test("[node/http] ClientRequest PATCH", async () => { Deno.test("[node/http] ClientRequest PUT", async () => { let body = ""; const { promise, resolve, reject } = Promise.withResolvers(); + // TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net const req = http.request("http://127.0.0.1:4545/echo_server", { method: "PUT", }, (resp) => { @@ -799,6 +807,7 @@ Deno.test("[node/http] ClientRequest search params", async () => { let body = ""; const { promise, resolve, reject } = Promise.withResolvers(); const req = http.request({ + // TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net host: "127.0.0.1", port: 4545, path: "/search_params?foo=bar", @@ -925,6 +934,7 @@ Deno.test( let body = ""; const request = http.request( + // TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net "http://127.0.0.1:5928/", (resp) => { resp.on("data", (chunk) => { @@ -993,6 +1003,7 @@ Deno.test( ); const { promise, resolve, reject } = Promise.withResolvers(); + // TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net const request = http.request("http://127.0.0.1:5929/"); request.on("error", reject); request.on("close", () => {}); @@ -1013,6 +1024,7 @@ Deno.test( "[node/http] client destroy before sending request should not error", async () => { const { resolve, promise } = Promise.withResolvers(); + // TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net const request = http.request("http://localhost:5929/"); // Calling this would throw request.destroy(); @@ -1569,6 +1581,7 @@ Deno.test("[node/http] ClientRequest PUT subarray", async () => { const payload = buffer.subarray(6, 11); let body = ""; const { promise, resolve, reject } = Promise.withResolvers(); + // TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net const req = http.request("http://127.0.0.1:4545/echo_server", { method: "PUT", }, (resp) => { @@ -1609,6 +1622,7 @@ Deno.test("[node/http] ClientRequest content-disposition header works", async () let body = ""; let headers = {} as http.IncomingHttpHeaders; const { promise, resolve, reject } = Promise.withResolvers(); + // TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net const req = http.request("http://127.0.0.1:4545/echo_server", { method: "PUT", headers: { @@ -1635,6 +1649,7 @@ Deno.test("[node/http] In ClientRequest, option.hostname has precedence over opt const responseReceived = Promise.withResolvers(); new http.ClientRequest({ + // TODO(kt3k): This should be "localhost" when we implemented happy-eyeballs for node:net hostname: "127.0.0.1", host: "invalid-hostname.test", port: 4545,