-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Undefined hostname defaults to 127.0.0.1 #12488
Comments
For some historical context: the current behavior is almost six years old to the day (commit a2328dc from April 25, 2011 and released in v0.5.0.) In other words, node has behaved this way for most of its life and it is a near certainty that changing it now would cause (possibly significant) ecosystem breakage. |
Good ol' let's perpetuate this bug because people rely on it argument? What about the good ol' solution to that? Detect |
Can I suggest you read through some of the issues that were filed after we started printing a deprecation warning for one thing or another? Better top up your coffee mug because some of the threads are epic. |
I believe the disagreement will lie more around whether this qualifies as a bug or not. I do not consider it to be so. It is well documented behavior that has been part of Node.js for six years. There is quite a non-trivial amount of code existing in the ecosystem that depends on this behavior that would be broken for no great reason. Historically, we have tried to err on the side of not breaking the ecosystem unless necessary to do so. |
Would anyone be able to come up with any other than historical reasons argument? I'm not going to read any of those issue comments @bnoordhuis suggested, I'm not a maintainer. Historical / compatibility / public outrage argument aside: I agree on all the defaults you have there except for hostname, which I think should not have a default value and should be required. Last, very important point that you didn't yet address in your response is the default stack trace which says nothing to the user. |
There is certainly room for improvement in the type checking for |
net APIs default to For stack trace, its an unfortunate reality of async engines that the stack trace doesn't include the original call location, bugs us all, no credible way to fix this has been thought of yet. Sorry. Or, perhaps you dislike that the message uses the IP address, instead of the hostname?
I can see how knowing the pre-resolved name as well as the resolved IP would be useful. |
Is the point I disagree on. It's very confusing IMO. It's as if you'd say that opening a file descriptor with |
You sound like you got burnt by this, and spent some nasty time debugging. I'm sympathetic, but one person's frustration doesn't mean its confusing to everybody. Be warned, that |
@sam-github thanks for the psychoanalysis, much appreciated. |
Well, if you didn't actually get burn by this, and it didn't cause any nastiness, but you just wanted to rant, I'm less sympathetic. Good day. |
Add type checking for options.hostname / options.host Maintains the use of `undefined` and `null` for default `localhost`, but other falsy values (like `false`, `0` and `NaN`) are rejected. PR-URL: #12494 Ref: #12488 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ali Ijaz Sheikh <[email protected]>
I'm not sure what's the idea behind defaulting to 127.0.0.1 in
http.request
whenhostname
isundefined
, but it's not a good one. Please throw an error whenhostname
is anything but string, telling the user she's an idiot, rather than defaulting to some arbitrary IP address causing potentially dangerous and destructive side-effects (what if Trump's nukes are on the same port on 127.0.0.1?)It's all cool that it's in the docs, but that doesn't mean it makes any sense or any good.
Common pitfall:
undefined
slips into the variable used to fillhostname
, and all the user gets is this:Not even a hint of what is going on, or where.
The text was updated successfully, but these errors were encountered: