-
Notifications
You must be signed in to change notification settings - Fork 29.5k
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
Possible bug in fetch() receiving chunked response #47528
Comments
With help of ChatGPT I think I found the problem.
So after replacing So its problem on |
See nodejs/node#47528 for more details
cc @nodejs/undici |
cc @nodejs/llhttp |
You are correct in saying the error is triggered by llhttp, which is strict by default (and thanks ChatGPT agres with us 😁 ). Lenient handling of useless spaces can be added to llhttp as a semver minor change behing a disabled-by-default flag. @nodejs/http Do we want/need this? |
For reference: the old C-based parser was tightened up at one point to reject superfluous spaces in most places because they're a source of desync attacks. It accepts them in sloppy mode but not in strict mode. Strict is the default. I believe llhttp copied that behavior from http_parser. Fedor was also the one who implemented the original behavior in http_parser, IIRC. |
I did some digging and on the C++ side node already calls Lines 638 to 644 in d3b0a2a
Node's http server does when you specify Pull request welcome for node's own http client on the provision that it doesn't change the default strict behavior. I don't think it should be overridable for fetch(). |
See nodejs/node#47528 for more details See me-no-dev#1301 for original PR from @zalupoi
Version
Tested v18.15.0 and v20.0.0-nightly2023041197d3912eb8
Platform
Microsoft Windows NT 10.0.19042.0 x64
Subsystem
No response
What steps will reproduce the bug?
Launch server.js
Launch client.js
How often does it reproduce? Is there a required condition?
No condition required.
What is the expected behavior? Why is that the expected behavior?
Script should display response from server.
What do you see instead?
Script crashes with
HPE_INVALID_CHUNK_SIZE
errorAdditional information
I write code for ESP32 using ESPAsyncWebServer library and its
request->beginChunkedResponse()
chunked respose feature.I captured data using Wireshark and reproduced it in
server.js
.You can open http://127.0.0.1:5000/ in web browser and it will work, but not in NodeJS's
fetch()
Chunks sizes are written here https://github.com/me-no-dev/ESPAsyncWebServer/blob/master/src/WebResponses.cpp#L312
The text was updated successfully, but these errors were encountered: