-
Notifications
You must be signed in to change notification settings - Fork 29.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
http core module issue #9069
Comments
The |
well shoot, maybe http should throw a better error when you pass an unacceptable value as an option..right? |
If it accepts |
right, this is a little weird tbh |
instead of false, it should accept null or undefined perhaps |
I've added the 'good first contribution' label but if no one picks it up within the next few weeks I'll go ahead and close it out as 'working as documented.' |
Ok so more definitely, here are the current docs on this: https://nodejs.org/api/http.html#http_http_request_options_callback it says:
Let's talk about the above, but as an aside, let's say we did allow seems like you could do this: => http.request options =>
so my thinking is here are the options:
So I think passing |
@the1mills, thanks for putting your thoughts into this. I have a few comments on your suggested options:
I'm not sure I agree with this. I don't think we should distinguish between
I'm not sure I understand the point of having an explicit option for In my opinion, the best course of action would be to simply allow |
I think it just makes things more weird. Having undefined (which is falsy) and false mean different things is odd, its not what someone would expect without reading the docs. I would expect null to be falsy, and be the same as undefined or false... but that can't work: falsy like undefined, or falsy like false? Hm... I don't think there is anything we can do here that would be expected, the best thing would be to throw clear errors on any use of an invalid argument value, and expect people to read the docs. |
I think We could use I don't think the API that I proposed above is overly confusing; if we allow |
Well, just my opinion here, but I still think this is rearranging the deck chairs on the titanic. It isn't going to make sense when undefined and false are defined to mean the opposite of each other. The sensible api would be:
but that's very semver major :-) And back to the main point. @the1mills got thrown off because of a terrible error message when they used the API in a way that was plainly documented to be wrong - just a decent error message would have avoided all this, and caused the OP to check the docs. Fixing that is a good first contribution! |
right I was saying agent:undefined is the same as should result in same thing as for agent:true, it needs to be one of three things: ~agent:false, (would not make sense at all) my vote is that agent:true procures some default agent of some variety
|
yeah I agree with Sam Roberts, I was talking in terms of semver minor, but
|
As per nodejs#9069 unexpected things can happen when supplying an unexpected value to agent. Beings as the docs clearly state the expected values, this throws an error on an unexpected value. Signed-off-by: brad-decker <bhdecker84@gmail.com>
As per #9069 unexpected things can happen when supplying an unexpected value to agent. Beings as the docs clearly state the expected values, this throws an error on an unexpected value. PR-URL: #10053 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
As per nodejs#9069 unexpected things can happen when supplying an unexpected value to agent. Beings as the docs clearly state the expected values, this throws an error on an unexpected value. PR-URL: nodejs#10053 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
I think the semver-major recommendation from @sam-github makes sense. But yeah... it's semver-major. In any case, it seems that this issue has been resolved with #10053 so I'm going to close this. Please feel free to reopen if I am mistaken. |
on Node.js 6.7
I got this while using require('http').request()
probably shouldn't be happening no matter what the input data is, but here it is:
curious as to what might be happening thanks, setting agent to false, will prevent this error being thrown...
The text was updated successfully, but these errors were encountered: