-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Better communication / errors around node 12 breaking HTTP parser changes #28468
Comments
@nodejs/http @indutny |
Was there ever a test for this? (I assume not.) I don't think that points 1-3 would have occurred to anyone if there was no test for this in the first place. There's probably other changes like this that we're completely unaware of. Now, I don't think it makes sense to add tests ensuring that forbidden behavior is supported; though there should have been a test for the required, correct behavior in the first place. I think a better written error message is the best solution. It appears Node.js does provide the error code, I think jumping straight to an error is appropriate; there's other clients that wouldn't be able to correctly parse this response, i.e. the program is already broken. I'm not sure how much more effort could reasonably be given to this. There's ten thousand of these little issues that pop up every time someone optimizes something; for example, at some point, Node.js broke one of my programs by rewriting querystring.parse to use String#indexOf instead of String#split; I was passing a regular expression to split the query string. I was possibly the only person using this behavior though, how worth it would it have been to have a transition period? Not very much, I assume. |
I think this is a combination of several different issues. One: the linked commit that introduced throwing an exception when encountering the combination of In this case, reading up on the private prior discussion, I assume the decision was made this way to make handling of similar situations easier (the linked commit addresses both points 3 and 4 of https://tools.ietf.org/html/rfc7230#section-3.3.3, although only multiple Content-Length headers are requires to be unrecoverable errors as per the spec). I read the spec text as saying that it would be acceptable to simply drop the Content-Length header in this situation. I’m not sure if this is better than throwing an exception, given that the sender can already send other header combinations that definitely lead to that outcome. I, personally, would not make changes to Node or its HTTP parser(s) at this point. Two: The lack of having a reason show up in Three: Release notes don’t always actually call out the really notable changes very well. (I’ve made an attempt to at least call out the “big” changes more directly for v12.x, although that would not have given the amount of information you’d like to see and it ultimately wasn’t included in the release). We run into this issue frequently with regular releases, because releasers aren’t always familiar with the subject matter of all commits, but for breaking changes I agree that we can and should do better. I’d suggest opening a separate issue in https://github.com/nodejs/Release about this, if you like. |
I've made an attempt to improve errors: https://gist.github.com/indutny/15352991e85a51786436646a31c790db, but this is a major change. Going to submit a PR once I'll fix all broken tests 😂 |
Include the library-provided reason in the Error’s `message`. Fixes: nodejs#28468
It looks way better than mine, so I'm glad to see you doing it! 😉 |
All: Thanks. 🙂 |
Include the library-provided reason in the Error’s `message`. Fixes: #28468 PR-URL: #28487 Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Previously, on Love Island
If a web server sends both a
Content-Length
header and aTransfer-Encoding: chunked
header, it is a violation of the HTTP spec.node 10's older HTTP parser didn't error on this (though it should have)
node 12's newer HTTP parser does error on this (which is good)
The issue
As a spicy noderperson, using a REST API client that worked with node 10, I recently moved it to node 12 and did a bunch of research trying to work out what was wrong before finding out the cause of this error.
Important thing since we're communicating of the internet and people tend not to read things before replying:
If it's not clear from the above, I believe node is doing the right thing here, It just needs to be communicated better. Please don't comment saying I support malformed headers, I don't support malformed headers. If you do comment saying I support malformed headers, I'll block you for non-constructive behaviour.
1. Robustness principle / Postel's law
See https://en.wikipedia.org/wiki/Robustness_principle
ie, node could have:
2. Lack of a transition period
Think about the good way node (as a community) is handling uncaught promises. There's a warning, everyone knows what's coming.
Ideally, a transition period could have occurred, ie:
3. Poor communication around a breaking change
If node was to break existing behaviour, a CHANGELOG entry that calls this out explicitly would help:
https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V12.md#12.0.0 states:
The change should be communicated more explicitly.
4.
error.message
around the malformed HTTP response is vagueerror.reason
) that has an explanation, buterror.message
itself is vague, and I didn't know abouterror.reason
(am I ignorant here? I thoughterror.message
was the reason)A better
error.message
would be:Error: invalid HTTP response. See https://someUrl
or perhaps:
Error: invalid HTTP response (contains both 'Content-Length' header and a 'Transfer-Encoding: chunked' header
)Just some suggestions. Thanks for reading.
The text was updated successfully, but these errors were encountered: