-
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
net.connect: behaviour when no arguments are passed #33930
Comments
IMO it should throw ping @nodejs/net |
I'm currently looking into this. Tried both of the suggestions, but they do not seem to be a clean solution. In my opinion, the problem is that the function Notice that the problem also relates to
|
Previously Node.js would handle empty `net.connect()` and `socket.connect()` call as if the user passed empty options object which doesn't really make sense. This was due to the fact that it uses the same `normalizeArgs` function as `.listen()` call where such call is perfectly fine. This will make it clear what is the problem with such call and how it can be resolved. It now throws `ERR_MISSING_ARGS` if no arguments were passed or neither `path` nor `port` is specified. Fixes: nodejs#33930
Previously Node.js would handle empty `net.connect()` and `socket.connect()` call as if the user passed empty options object which doesn't really make sense. This was due to the fact that it uses the same `normalizeArgs` function as `.listen()` call where such call is perfectly fine. This will make it clear what is the problem with such call and how it can be resolved. It now throws `ERR_MISSING_ARGS` if no arguments were passed or neither `path` nor `port` is specified. Fixes: #33930 PR-URL: #34022 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Zeyu Yang <[email protected]>
For the quote above outlined in #33715 (comment), two solutions come to mind.
ERR_MISSING_ARGS
when no arguments are passed (as suggested above -- invalid usage).port: undefined
andport: null
, either makeport
a mandatory field that throwsERR_INVALID_ARGS
for anything other than string or numeric values or don't throwERR_INVALID_ARGS
forport: null
. This needs more brainstorming.I'd appreciate a few pointers here to see where this should be going.
cc @sam-github
The text was updated successfully, but these errors were encountered: