Repository: nodejs/undici

Issue #902: HTTP2 Basic Support
Created: 2021-07-25T03:35:25Z
Hi Hi!
The library would be awesome with even basic HTTP2 support (even without pushes), any lead date?

Duplicate issue #1412: `fetch` throws UND_ERR_SOCKET error
Created: 2022-05-04T10:20:09Z
Bug Description
A request on this page of the Daily Mail throws an UND_ERR_SOCKET error. There is no problem with https.
Reproducible By
Execute this script:
import https from "node:https";
import zlib from "node:zlib";

const testWithHttps = (url) => {
    return new Promise((resolve, reject) => {
        const req = https.request(new URL(url), (res) => {
            const gunzip = zlib.createGunzip();
            res.pipe(gunzip);

            const buffer = [];
            gunzip.on("data", (chunk) => buffer.push(chunk))
                  .on("error", (err) => reject(err))
                  .on("end", () => resolve(buffer.join("")));
        });
        req.on("error", (err) => reject(err));
        req.setHeader("Accept", "*/*");
        req.setHeader("Accept-Encoding", "br, gzip, deflate");
        req.setHeader("Accept-Language", "*");
        req.setHeader("Sec-Fetch-Mode", "cors");
        req.setHeader("User-Agent", "undici");
        req.end();
    });
};

const testWithFetch = async (url) => {
    const response = await fetch(url);
    return response.text();
};


console.log("PTS (https://ptsv2.com/t/undici)");
let url = "https://ptsv2.com/t/undici/post";
console.log("HTTPS: " + (await testWithHttps(url)).substring(0, 100));
console.log("FETCH: " + (await testWithFetch(url)).substring(0, 100));

console.log("\nDaily Mail");
url = "https://www.dailymail.co.uk/sciencetech/article-8057229" +
                                  "/Scientists-create-stunning-gifs-Mars-sand" +
                                "-dunes-understand-conditions-impact-them.html";
console.log("HTTPS: " + (await testWithHttps(url)).substring(0, 100));
console.log("FETCH: " + (await testWithFetch(url)).substring(0, 100));
Expected Behavior
PTS (https://ptsv2.com/t/undici)
HTTPS: Thank you for this dump. I hope you have a lovely day!
(node:22125) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
FETCH: Thank you for this dump. I hope you have a lovely day!

Daily Mail
HTTPS: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "//www.w3.org/TR/xhtml1/DTD/xhtml1-tr
FETCH: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "//www.w3.org/TR/xhtml1/DTD/xhtml1-tr

Logs & Screenshots
PTS (https://ptsv2.com/t/undici)
HTTPS: Thank you for this dump. I hope you have a lovely day!
(node:22125) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
FETCH: Thank you for this dump. I hope you have a lovely day!

Daily Mail
HTTPS: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "//www.w3.org/TR/xhtml1/DTD/xhtml1-tr
node:internal/deps/undici/undici:6266
            fetchParams.controller.controller.error(new TypeError("terminated", {
                                                    ^

TypeError: terminated
    at Fetch.onAborted (node:internal/deps/undici/undici:6266:53)
    at Fetch.emit (node:events:527:28)
    at Fetch.terminate (node:internal/deps/undici/undici:5522:14)
    at Object.onError (node:internal/deps/undici/undici:6357:36)
    at Request.onError (node:internal/deps/undici/undici:2023:31)
    at errorRequest (node:internal/deps/undici/undici:3949:17)
    at TLSSocket.onSocketClose (node:internal/deps/undici/undici:3411:9)
    at TLSSocket.emit (node:events:539:35)
    at node:net:715:12
    at TCP.done (node:_tls_wrap:581:7) {
  [cause]: SocketError: closed
      at TLSSocket.onSocketClose (node:internal/deps/undici/undici:3399:35)
      at TLSSocket.emit (node:events:539:35)
      at node:net:715:12
      at TCP.done (node:_tls_wrap:581:7) {
    code: 'UND_ERR_SOCKET',
    socket: {
      localAddress: undefined,
      localPort: undefined,
      remoteAddress: undefined,
      remotePort: undefined,
      remoteFamily: 'IPvundefined',
      timeout: undefined,
      bytesWritten: 294,
      bytesRead: 83018
    }
  }
}

Node.js v18.1.0

Environment

Ubuntu: 20.04.4 LTS
Node: v18.1.0
npm: 8.8.0

Additional context
In test case, I modified the https headers to have the same values as fetch. You can see the requests (with their headers) on this page of PTS.

Closing comment (2023-02-10T14:51:16Z): Closing as a duplicate of #902.
fetch is missing HTTP/2 support.