fix(h2): forward 1xx informational responses to onInfo - #5712
Open
pacocartones wants to merge 1 commit into
Open
fix(h2): forward 1xx informational responses to onInfo#5712pacocartones wants to merge 1 commit into
pacocartones wants to merge 1 commit into
Conversation
onInfo is documented as invoked for each 1xx informational response. HTTP/1 forwards them (client-h1.js, statusCode < 200 -> onResponseStart) but HTTP/2 only listens for the stream response event, never the headers event where Node emits informational headers, so 102/103 are silently dropped on h2 and onInfo never fires. Subscribe to headers and forward via onResponseStart, matching h1 and the same guards as onResponse; only :status is stripped. Adds test/http2-informational.js (103 Early Hints): fails before, passes after.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5712 +/- ##
=======================================
Coverage 93.47% 93.47%
=======================================
Files 110 110
Lines 38906 38932 +26
=======================================
+ Hits 36366 36391 +25
- Misses 2540 2541 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
What
onInfois documented as "Invoked for each informational (1xx) response. May be invoked multiple times." HTTP/1 forwards them —client-h1.jsonHeadersCompleteforwards astatusCode < 200viaonResponseStart. HTTP/2 does not: it only subscribes to the streamresponseevent (the final response) and never to theheadersevent, where Node emits informational headers. So 1xx responses (102 Processing, 103 Early Hints) are silently dropped on h2 andonInfonever fires.Why it matters
103 Early Hints is increasingly used for preload/preconnect, and it is exactly the kind of thing an h2/CDN path serves. Any
client.request({ onInfo })over an ALPN-negotiated h2 connection loses them today, diverging from h1 with no documented reason.The fix
Subscribe to the stream
headersevent and forward viaonResponseStart, matching the h1 path and reusing the samestate == null/aborted || completedguards asonResponse. Only the:statuspseudo-header is stripped; 1xx responses carry no other response pseudo-headers.stream.on('response', onResponse) + stream.on('headers', onInterimResponse) stream.on('end', onEnd)(plus the matching
offin the listener teardown, and theonInterimResponsehandler).Test
Adds
test/http2-informational.js: an h2 server emits a 103 Early Hints viaadditionalHeadersbefore the 200, and the test assertsonInforeceives it with itslinkheader. It fails onmain(infos.length0 vs 1) and passes with the change.Reachability is plain:
allowH2: true(or anAgentnegotiating h2) against any server that sends 1xx. No custom store or exotic config.