Repository navigation
fix(ext/node): improve http server parser compat - #34094
bartlomieju merged 4 commits into
Conversation
|
@lunadogbot please review |
fibibot
left a comment
There was a problem hiding this comment.
Found one behavioral mismatch with Node's optimizeEmptyRequests implementation.
isRequestKnownEmpty() returns true for all HEAD requests, even when the request has Content-Length or Transfer-Encoding. With createServer({ optimizeEmptyRequests: true }), a HEAD request with body framing headers will be passed through _dumpAndCloseReadable() before user code sees it, so applications can no longer read or observe that request stream. Upstream Node gates this optimization only on the absence of body headers (!hasBodyHeaders(req.headers)), not on the method. Please drop the HEAD special case and base this solely on missing body headers.
I could not run the targeted compat tests locally because this VM has no cargo in PATH; GitHub CI is green.
fibibot
left a comment
There was a problem hiding this comment.
The revised head removes the HEAD shortcut, so isRequestKnownEmpty() now matches Node's documented condition: no Content-Length and no Transfer-Encoding. The raw-packet plumbing for collapsed llhttp errors is scoped to parse errors / upgrades, and the parser cleanup clears _lastRawPacket.
CI is green.
lunadogbot
left a comment
There was a problem hiding this comment.
The current head removes the HEAD shortcut in isRequestKnownEmpty(), so optimizeEmptyRequests now follows the node_test cases: requests with either Content-Length or Transfer-Encoding stay readable, regardless of method. The raw-packet plumbing feeds collapsed llhttp errors into prepareError() on both consume and socket paths, and cleanParser() clears _lastRawPacket before parser reuse.
CI is green.
This reverts commit a05f9c1.
lunadogbot
left a comment
There was a problem hiding this comment.
if (req.method === "HEAD") return true;reintroduces the Node mismatch from the previous review. Node 25.8.1's_http_server.jsoptimizes only when!hasBodyHeaders(req.headers), so aHEADrequest withContent-LengthorTransfer-Encodingmust remain readable; this shortcut dumps it before user code can observe the stream. Drop theHEADbranch or guard it with the same body-header check.
The imported node_test currently only sends HEAD without body headers, so it does not cover this regression. CI is still running on this head.
lunadogbot
left a comment
There was a problem hiding this comment.
The current head removes the HEAD branch from isRequestKnownEmpty(), so optimizeEmptyRequests now leaves HEAD requests with Content-Length or Transfer-Encoding readable while still dumping known-empty requests. That resolves the Node compat blocker from the previous review.
Holding approval until CI finishes on this SHA.
fibibot
left a comment
There was a problem hiding this comment.
The current head removes the HEAD branch from isRequestKnownEmpty(), so optimizeEmptyRequests now follows Node's !hasBodyHeaders(req.headers) rule: requests with Content-Length or Transfer-Encoding stay readable. Passing the raw packet into onParserExecute() for consume-path errors also gives prepareError() enough bytes to recover HPE_INVALID_TRANSFER_ENCODING, and cleanParser() clears _lastRawPacket before parser reuse.
Holding approval until test specs (2/2) release linux-x86_64 finishes.
lunadogbot
left a comment
There was a problem hiding this comment.
CI is red because test specs (2/2) release linux-x86_64 was cancelled after the other shards passed; flake-watcher will triage. Holding approval until a green run lands.
fibibot
left a comment
There was a problem hiding this comment.
CI is green now, promoting prior review to APPROVE.
- pass raw parser input to JS for consumed-handle parse errors so
HPE_ERROR can be classified as HPE_INVALID_TRANSFER_ENCODING
- retain the last raw parser packet for EOF parser errors
- implement http.createServer({ optimizeEmptyRequests: true }) for
known-empty requests
- enable the now-passing Node compat tests
Summary
Tests