Recently at Speakeasy, we received a report that a user was unable to hit an HTTP/2 endpoint from the TypeScript SDK they generated with our code gen

Fetch and HTTP/2 support in Node.js, Bun and Deno

submited by
Style Pass
2025-01-19 16:30:06

Recently at Speakeasy, we received a report that a user was unable to hit an HTTP/2 endpoint from the TypeScript SDK they generated with our code generator. I was a little surprised because I didn’t think this was going to be a problem. Our SDKs are built using the Web Fetch API and avoid using any non-standard polyfills like node-fetch or similar packages. The Fetch Standard is very much written with HTTP/2 in mind and it’s easy to think this would be table stakes. On the popular, everygreen browsers, you can open the network tab in developer tools on many sites that use fetch for API calls and often observe these happening over HTTP/2.

Of course, the situation with backend JavaScript is rather different. With a small test setup I found that Node.js, Bun and Deno have varying support which may either be opt-in or outright unavailable.

Probably the strangest thing from the user’s bug report was that the server they were connecting to did not allow HTTP/1.1 clients. This was a novel setup since many server frameworks, proxies and CDNs seamlessly support HTTP/2 with backwards compatibility for HTTP/1.1. It’s not something you think about unless perhaps you’re running a file upload or streaming service where things like request body streaming are central concerns.

Leave a Comment