denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
94.94k stars 5.27k forks source link

Http: error sending request for url (<URL>): http2 error: protocol error: endpoint requires HTTP/1.1 #8333

Closed breezy-badger closed 3 weeks ago

breezy-badger commented 3 years ago

Certain requests that work through Chrome console(and Node as well) fails through deno.

Steps to reproduce

$ cat test.js
fetch("https://localhost:4000").catch(console.log)
$ deno run --allow-all ./test.js
Http: error sending request for url (https://localhost:4000): http2 error: protocol error: endpoint requires HTTP/1.1
    at processResponse (core.js:224:13)
    at Object.jsonOpAsync (core.js:242:12)
    at async fetch (deno:op_crates/fetch/26_fetch.js:1274:29)

Expected result

That deno supports https/2

In case the provided error-message isn’t enough, I can find an external URL where the issue can be reproduced.

kitsonk commented 3 years ago

Deno fetch() does not currently support HTTP/2. The server you are connecting to only supports HTTP/2, therefore the error.

Duplicate of #3995

lucacasonato commented 3 years ago

@kitsonk fetch() does support HTTP/2 (it is done by reqwest in Rust).

Skillz4Killz commented 3 years ago

Not sure if this is entirely related but the issue feels very similar. My libs users have been reporting this to me and I have no idea what could be causing it.

image

lucacasonato commented 3 years ago

@breezy-badger We'll need more details. Do you have a test case I can execute that fails?

breezy-badger commented 3 years ago

@lucacasonato

$ cat test.js fetch("https://book.hotelvejlefjord.dk/umbraco/api/hotel/available?lang=da-DK&arrival=2021-08-13&departure=2021-08-14&participants=2").catch(console.log)

$deno run --allow-all ./test.js TypeError: error sending request for url (https://book.hotelvejlefjord.dk/umbraco/api/hotel/available?lang=da-DK&arrival=2021-08-13&departure=2021-08-14&participants=2): http2 error: protocol error: endpoint requires HTTP/1.1 at deno:core/01_core.js:106:46 at unwrapOpResult (deno:core/01_core.js:126:13) at async mainFetch (deno:extensions/fetch/26_fetch.js:253:14)

It might be caused by this booking system returning the Http 204 status code for dates with no available rooms https://book.hotelvejlefjord.dk/da/step/1?arrival=2021-08-13&departure=2021-08-14&rooms=%5B%7B%22services%22:%5B%5D,%22adults%22:2,%22roomType%22:null%7D%5D

While that might be a bit strange, it should still be handled. Be aware that the provided example above might not fail later today or tomorrow if a room becomes available. If that is the case, I guess I have to find a new date without a room for two people ;)

breezy-badger commented 3 years ago

The above code works fine in both Chrome console as well as Node.

lucacasonato commented 3 weeks ago

I can not reproduce this using either of the reproductions anymore. Please re-open if you still run into this.