-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
net: throw error if port does not exist in options #22085
net: throw error if port does not exist in options #22085
Conversation
Semver-major because of the addition of a new throw. @nodejs/tsc ... PTAL. I'm not yet convinced this is definitely something we should do. |
Hi, @yanivfriedensohn and welcome! Thanks for the PR. I think the added error is not quite right. If I understand correctly, |
Hi @Trott, based on your suggestions, I added an additional error message argument to |
c75c291
to
dc961c8
Compare
@yanivfriedensohn Would you be able to add some tests for the new behavior? We can run CI on this after that |
How does this fix #16712 ? It requested
|
Note that |
8bed77c
to
7498e3c
Compare
@maclover7 I added tests for the additional error message. @joyeecheung this fixes:
The message mentions that |
@yanivfriedensohn In that case please do not put |
lib/net.js
Outdated
@@ -1496,7 +1496,15 @@ Server.prototype.listen = function(...args) { | |||
return this; | |||
} | |||
|
|||
throw new ERR_INVALID_OPT_VALUE('options', util.inspect(options)); | |||
let additionalMessage; | |||
if (typeof options === 'object' && |
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.
typeof options === 'object'
here is always true since it's normalized before
lib/net.js
Outdated
additionalMessage = '"port" or "path" must be specified in options.'; | ||
} | ||
|
||
throw new ERR_INVALID_OPT_VALUE('options', util.inspect(options), |
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.
This error message will not be accurate since options
is an argument, not an option value - the user does not pass { options: { ... } }
to this method. ERR_INVALID_ARG_VALUE
may be more accurate.
7498e3c
to
4862c1f
Compare
@joyeecheung following your suggestion, I used |
Tests have been added so I've removed the |
@joyeecheung is this ready for CI? |
Throw error ERR_PROPERTY_NOT_IN_OBJECT if the port property does not exist in the options object argument when calling server.listen(). Refs: nodejs#16712
4862c1f
to
630d987
Compare
Rebased and force pushed to resolve the dreaded jinja LICENSE CRLF thing. (I think we'll all be happy when that problem is a few weeks in the past.) |
Resume Build: https://ci.nodejs.org/job/node-test-pull-request/16705/ |
@Trott is this |
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 in 4a0466f 🎉 |
Throw error ERR_INVALID_ARG_VALUE if the port and path properties do not exist in the options object argument when calling server.listen(). Refs: #16712 PR-URL: #22085 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Throw error ERR_PROPERTY_NOT_IN_OBJECT if the port property does not
exist in the options object argument when calling server.listen().
Refs: #16712
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes#SimilarWeb_RnD