-
Notifications
You must be signed in to change notification settings - Fork 567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fetch
throws UND_ERR_SOCKET error
#1412
Comments
Could you reproduce with a self-hosted server? |
@mcollina I reproduce the same error with a secure HTTP2 server. // node server.js
import fs from "node:fs/promises";
import http2 from "node:http2";
// openssl genrsa -out key.pem
// openssl req -new -key key.pem -out csr.pem
// openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem
// rm csr.pem
const server = http2.createSecureServer({
key: await fs.readFile("key.pem"),
cert: await fs.readFile("cert.pem"),
});
server.on("error", (err) => console.log(err));
server.on("stream", (stream) => stream.end("foo"));
server.listen(11011); // NODE_TLS_REJECT_UNAUTHORIZED='0' node client.js
import http2 from "node:http2";
const testWithHttp2 = (url) => {
return new Promise((resolve, reject) => {
const client = http2.connect(url);
const req = client.request();
const buffer = [];
req.on("data", (chunk) => buffer.push(chunk));
req.on("error", (err) => reject(err));
req.on("end", () => {
resolve(buffer.join(""));
client.close();
});
req.end();
});
};
const testWithFetch = async (url) => {
const response = await fetch(url);
return response.text();
};
let url = "https://localhost:11011/";
console.log("HTTP2: " + (await testWithHttp2(url)));
console.log("FETCH: " + (await testWithFetch(url)));
With a unsecure HTTP2 server,
There is issues and pull request to add support for HTTP/2: |
undici doesn't support http2 yet |
I have the same issue with this url |
Closing as a duplicate of #902. |
I encountered this many times earlier today using a flakey network with node v20.15.1. The network conditions here have improved so that I'm no longer seeing the issue. No problem for me, this is just a friendly comment sharing my experience that an issue still exists at node v20 |
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:
Expected Behavior
Logs & Screenshots
Environment
Additional context
In test case, I modified the
https
headers to have the same values asfetch
. You can see the requests (with their headers) on this page of PTS.The text was updated successfully, but these errors were encountered: