fix(ext/fetch): raise default HTTP/2 SETTINGS_MAX_HEADER_LIST_SIZE to 256KB - #36558
Open
bartlomieju wants to merge 1 commit into
Open
fix(ext/fetch): raise default HTTP/2 SETTINGS_MAX_HEADER_LIST_SIZE to 256KB#36558bartlomieju wants to merge 1 commit into
bartlomieju wants to merge 1 commit into
Conversation
… 256KB
hyper defaults the HTTP/2 client's SETTINGS_MAX_HEADER_LIST_SIZE to 16KB.
Responses with large header blocks (e.g. long content-security-policy or
many set-cookie headers) exceed this and get rejected by the h2 layer with
a stream PROTOCOL_ERROR before ever reaching JavaScript, surfacing as
'TypeError: fetch failed'. Browsers and curl allow much larger header
lists, so such responses work everywhere except Deno.
Default the limit to 256KB (matching the value Chrome advertises) so
fetch() interoperates with the same servers browsers do. Users can still
override it via Deno.createHttpClient({ http2MaxHeaderListSize }).
Closes denoland#36462
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #36462.
Problem
fetch()ing certain HTTP/2 responses fails withTypeError: fetch failed(
stream error detected: unspecific protocol error detected) while the samerequest works with
curland Node.Root cause
hyper defaults the HTTP/2 client's
SETTINGS_MAX_HEADER_LIST_SIZEto 16KB.When a server sends a response with a large header block (e.g. a long
content-security-policyheader, or manyset-cookie/x-*headers), thedecoded header list exceeds 16KB and the
h2layer resets the stream with aPROTOCOL_ERRORbefore the response ever reaches JavaScript.Confirmed with h2 tracing on the reproducer from the issue:
Browsers and curl advertise much larger limits, so these responses work
everywhere except Deno.
Fix
Default the client
SETTINGS_MAX_HEADER_LIST_SIZEto 256KB (the valueChrome advertises) instead of hyper's 16KB, so
fetch()interoperates with thesame servers browsers do. Users can still override it via
Deno.createHttpClient({ http2MaxHeaderListSize }).Tests
/large_headerstest-server route to ~29KB decoded(over the old 16KB default, under the 64KB the existing "large enough" test
uses).
fetchHttp2LargeHeadersDefaultregression test: a default clientfetching a large-header response now succeeds.
Verified the reproducer URL now returns
200, and that the old binary rejectsthe enlarged route while the patched binary accepts it.