-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
errors: change ERR_HTTP2_HEADER_SINGLE_VALUE to instance of TypeError #19805
Conversation
changes the base instance for ERR_HTTP2_HEADER_SINGLE_VALUE from Error to TypeError as a more accurate representation of the error. Additionally corrects the grammar of the error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if CI is green.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe (probably?) I misunderstand something, but if I understand correctly, then I disagree that this is a TypeError
.
If you expect an array and you get a string, that's a TypeError
.
If you get an array with four values, but you expect an array with 1 value, that is not a TypeError
.
If you expect an object with certain keys, but get an object with additional unexpected keys, that is also not a TypeError
.
Although the definition of https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror:
|
But that's a draft. :-D Current spec is more aligned with what I'm saying...
¯\(ツ)/¯ |
pinging people that have a reason to read/understand the spec and might have an opinion one way or the other: @TimothyGu @nodejs/v8 |
We actually do not always adhere to the spec. Neither do the browsers. It is often used in general if the input is not as expected. |
there are two cases where this error occurs:
I think it could be indeed be argued that this is a |
What's the benefit of having this be a |
classification accuracy. but granted, if it's agree it doesn't fit in any classification, |
I'd suggest simply removing that comment. :-D |
@Trott as I pointed out: this is actually in line with the way errors are mainly implemented in core. A generic |
happy to change as necessary @jasnell - with your familiarity with HTTP2, what's your thoughts? === edit - you're -> your |
I believe |
I see the value of "this is something you did in your code, and not a problem with Node.js". But I don't think this generalization is correct. (ERR_ASSERTION, ERR_CANNOT_WATCH_SIGINT, ERR_CHILD_CLOSED_BEFORE_REPLY, and many many many more...) Moreover, I think the basic suggestion of all those comments in |
@jasnell Can you explain the "general convention" that you are referring to? Only thing I can come up with would be "Invalid input should automatically be treated as a |
I'm happy with this change but I'm not passionate enough about the exact semantics of |
@Trott about the convention: if you look at all the errors in So e.g., Almost all |
So then... do we
|
@BridgeAR Well, that list is pretty hard to argue with. I would prefer we go the other direction and make those things (that are already (For what it's worth, my thinking is: Any error is DEFINITELY an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Landed as ef07d65. |
changes the base instance for ERR_HTTP2_HEADER_SINGLE_VALUE from Error to TypeError as a more accurate representation of the error. Additionally corrects the grammar of the error message. PR-URL: #19805 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Since HTTP2 is still experimental, it actually does not have to be semver-major. |
changes the base instance for ERR_HTTP2_HEADER_SINGLE_VALUE from Error to TypeError as a more accurate representation of the error. Additionally corrects the grammar of the error message. PR-URL: #19805 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
changes the base instance for ERR_HTTP2_HEADER_SINGLE_VALUE
from Error to TypeError as a more accurate representation
of the error. Additionally corrects the grammar of the error
message.
Arguably the error type could also be
RangeError
, but only in caseswhere a header key in an object is assigned an array with more than one
element, instead of a string. However, this inconsistency could be confusing
and unnecessarily complex/convoluted. It could also be (possibly weakly) argued
that a "type" in JS is defined by object shape, so an object that's an instance of
Array
,with one key (
0
) is the expected type.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes