Skip to content
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() hangs when receiving large headers over HTTP/2 #27830

Open
danopia opened this issue Jan 26, 2025 · 0 comments
Open

fetch() hangs when receiving large headers over HTTP/2 #27830

danopia opened this issue Jan 26, 2025 · 0 comments

Comments

@danopia
Copy link
Contributor

danopia commented Jan 26, 2025

Version: Deno 2.1.7

I've found that Deno's h2 implementation is hanging fetch() calls when an HTTP2 error occurs.
In this case, the response headers are very large (~20kb). Deno seems to be dropping the transaction because of stream error REQUEST_HEADER_FIELDS_TOO_LARGE without resolving or rejecting the promise, so the fetch() call waits forever.

reproduction

I have set up a reproduction endpoint that can be used like so:

# expected behavior:
$ curl https://eo82u4jujnkymoi.m.pipedream.net
You got the response!

# will just hang forever:
$ deno run --allow-net https://deno.land/[email protected]/examples/curl.ts https://eo82u4jujnkymoi.m.pipedream.net
# ...

debug log

I have captured a debug log, which is how I was finally able to see what the actual issue was (I spent at least an hour finding the trigger 😓)

$ deno run -L debug --allow-net https://deno.land/[email protected]/examples/curl.ts https://eo82u4jujnkymoi.m.pipedream.net
# ... deno startup
DEBUG RS - hyper_util::client::legacy::connect::dns:121 - resolve; host=eo82u4jujnkymoi.m.pipedream.net
DEBUG RS - hyper_util::client::legacy::connect::http:657 - connecting to 44.198.101.178:443
DEBUG RS - hyper_util::client::legacy::connect::http:660 - connected to 44.198.101.178:443
DEBUG RS - h2::client:1281 - binding client connection
DEBUG RS - h2::client:1286 - client connection bound
DEBUG RS - h2::codec::framed_write:213 - send frame=Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384, max_header_list_size: 16384 }
DEBUG RS - h2::proto::connection:138 - Connection; peer=Client
DEBUG RS - hyper_util::client::legacy::pool:396 - pooling idle connection for ("https", eo82u4jujnkymoi.m.pipedream.net)
DEBUG RS - h2::codec::framed_read:405 - received frame=Settings { flags: (0x0), max_concurrent_streams: 128, initial_window_size: 65536, max_frame_size: 16777215 }
DEBUG RS - h2::codec::framed_write:213 - send frame=Settings { flags: (0x1: ACK) }
DEBUG RS - h2::codec::framed_read:405 - received frame=WindowUpdate { stream_id: StreamId(0), size_increment: 2147418112 }
DEBUG RS - h2::codec::framed_write:213 - send frame=WindowUpdate { stream_id: StreamId(0), size_increment: 5177345 }
DEBUG RS - h2::codec::framed_write:213 - send frame=Headers { stream_id: StreamId(1), flags: (0x5: END_HEADERS | END_STREAM) }
DEBUG RS - h2::codec::framed_read:405 - received frame=Settings { flags: (0x1: ACK) }
DEBUG RS - h2::proto::settings:56 - received settings ACK; applying Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384, max_header_list_size: 16384 }
DEBUG RS - h2::codec::framed_read:405 - received frame=Headers { stream_id: StreamId(1), flags: (0x4: END_HEADERS) }
DEBUG RS - h2::proto::streams::recv:203 - stream error REQUEST_HEADER_FIELDS_TOO_LARGE -- recv_headers: frame is over size; stream=StreamId(1)
DEBUG RS - h2::codec::framed_read:405 - received frame=Data { stream_id: StreamId(1) }
DEBUG RS - h2::codec::framed_read:405 - received frame=Data { stream_id: StreamId(1), flags: (0x1: END_STREAM) }
DEBUG RS - h2::codec::framed_write:213 - send frame=Reset { stream_id: StreamId(1), error_code: REFUSED_STREAM }
# hangs forever

workaround

Disabling http2 for the fetch call via Deno.createHttpClient({http2: false})

danopia added a commit to cloudydeno/deno-docker_registry_client that referenced this issue Jan 26, 2025
danopia added a commit to cloudydeno/deno-docker_registry_client that referenced this issue Jan 26, 2025
danopia added a commit to cloudydeno/denodir-oci that referenced this issue Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant