I asked OpenAI’s GPT-3 if it was possible to make an HTTP/3 request with Node.js, and the result was weird.

Can you make an HTTP/3 request with Node.js? I asked that question on OpenAI’s playground to see how it handles the question that doesn’t have the answer.

Yes, you can make an HTTP/3 request with Node.js using the node-quic module. This module provides an interface to the IETF QUIC protocol and allows you to make HTTP/3 requests.

AI

That’s what the system replied in OpenAI’s Playground. I was curious if that was at least partially true, so I asked more follow-up questions.

Anything better than that? The module seems abandoned and is rarely downloaded.

Me

Yes, there are other alternatives to node-quic for making HTTP/3 requests with Node.js. Some popular options are node-http3, node-http3-client, and quiche.

AI

Wow, so many options. Sounds too good to be true. Last time I tried to find something, only the C libraries and command line tools popped up. Besides, quiche was a Google’s library for other projects, not a Node.js module. So I asked for details.

Give me the links to those.

Me

node-http3: https://www.npmjs.com/package/node-http3

node-http3-client: https://www.npmjs.com/package/node-http3-client

quiche: https://www.npmjs.com/package/quiche

AI

Lie, lie, lie… If the AI was so sure about it, I asked for some code examples. And he/she gave it to me…

Here is an example of how to make an HTTP/3 request using quiche:

AI
const quiche = require("quiche");
const url = "https://example.com";

const req = quiche.request({
  url: urlURL,
  method: "GET",
  headers: {
    "Content-Type": "application/json"
  }
});

req.end();

req.on("response", (res) => {
  console.log(res.statusCode);
  res.on("data", (d) => {
    console.log(d.toString());
  });
});

It’s all wrong. Quiche is a Google Image Charts Node.js wrapper, the code also has a typo in url: urlURL, which is a silly mistake for the most novice programmer, yet still hard to understand for the AI. I fought back:

Are you sure? it says quiche is a Node.js wrapper for Google Image Charts – Chart Tools (deprecated by Google)

Me

No, quiche is an HTTP/3 library for Node.js. It was originally a Node.js wrapper for Google Image Charts – Chart Tools (which is now deprecated by Google), but it has since been updated to include support for making HTTP/3 requests.

AI

OMG, no!

Sorry, but this is not true. The code you provided is invalid.

Me

Sorry about that. The code I provided was incorrect. Here is a valid example of how to make an HTTP/3 request using quiche:

AI

Here we go again… it attempted to give me the code one more time, but with a fixed url: url. I had to repeat and point out the mistakes again:

Again, the quiche module is for something else, it doesn’t even have a .request() method.

Me

Yes, you are correct. The quiche module is not intended for making HTTP/3 requests. The examples I provided were incorrect and should not be used. The correct module for making HTTP/3 requests is node-http3. Here is an example of how to make an HTTP/3 request using node-http3:

AI
const http3 = require("node-http3");
const url = "https://example.com";

http3
  .get(URL, {
    headers: {
      "Content-Type": "application/json"
    }
  })
  .then((res) => {
     console.log(res.statusCode);
     console.log(res.body);
  });

node-http3 is not available on npm.

Me

Yes, you are correct. node-http3 is not available on npm. However, you can still use it to make HTTP/3 requests by downloading the source code from the GitHub repository: https://github.com/node-http3/node-http3

AI

Seriously?..

It doesn’t exist on GitHub either.

Me

No, node-http3 does exist in GitHub. You can access the source code and documentation here: https://github.com/node-http3/node-http3

AI

No, you cannot. It gives a 404 error

Me

Yes, you are correct. The link I provided is no longer working and the node-http3 module appears to be abandoned. However, there are other alternatives to node-http3 for making HTTP/3 requests with Node.js. Some popular options are node-http3-client and quiche.

AI

node-http3-client doesn’t exist and quiche is a different thing (not a Node.js module).

Me

Yes, you are correct. The node-http3-client module does not exist and quiche is not an HTTP/3 library for Node.js. However, there are other alternatives for making HTTP/3 requests with Node.js. Some popular options are node-quic and http3-client.

AI

Come on! Think!

They don’t exist.

Me

Yes, you are correct. node-quic is no longer actively maintained and http3-client is a relatively new library that is still in the early stages of development. However, there are other alternatives for making HTTP/3 requests with Node.js. One popular option is node-http3, which can be downloaded from GitHub: https://github.com/node-http3/node-http3

AI

I already mentioned before, that those alternatives don’t exist. Any other option?

Me

Yes, there are other alternatives to making HTTP/3 requests with Node.js. One popular option is the nghttp2 library, which provides an interface to the IETF QUIC protocol and allows you to make HTTP/3 requests. You can find the source code and documentation for nghttp2 here: https://github.com/nghttp2/nghttp2

AI

It found a C library. At this point, it became clear that since Node.js contains a lot of C/C++ code, the AI thought anyone could just use a random C library without any additional work. I stopped asking the AI…

The state of HTTP/3 in Node.js

As of Feb 2023, we are still waiting for the implementation. However, there’s already a lot of work in progress. The issue is alive on GitHub, and the pull requests are being updated, so the hopes are high. Besides, various clients already exist for Python, Rust and such, making Node.js the last in the queue. All the browsers already support it except Safari – the new IE, where it can only be enabled as an experimental feature, but that’s a matter of wide adoption.

Resources


Did you know that I made an in-browser image converter, where you can convert your images without uploading them anywhere? Try it out and let me know what you think. It's free.

Leave a Comment

Your email address will not be published. Required fields are marked *