-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: remove unreachable error #24222
Conversation
When creating a socket, if the file descriptor is not a valid PIPE or TCP type, createHandle throws an ERR_INVALID_FD_TYPE. This means that `this._handle.open` is guaranteed to succeed and will never return an error.
d259599
to
d961de0
Compare
Amended the commit to remove trailing whitespaces on a line 270 |
I hate to say this, but: This call is not guaranteed to succeed. There are a number of situations in which it doesn’t, but it might be hard to artificially create them in a cross-platform way? However: There is a discrepancy here between I’m not sure which one I’d prefer, but it’s probably a better idea to align the two, and figure out how to cover it rather than to remove error checking. |
I couldn't figure out how to create a file descriptor that both passes the |
@bewchy Yeah, I’m having a hard time too. But there’s a bunch of error conditions in the libuv code behind this, and some of them are very platform-specific (e.g. only macOS/only Windows)… For example, I think this fails on Windows if |
So how about we go to the code that |
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.
I'm putting this "Request Changes" here so that no one accidentally lands this in a crush of Code & Learn PRs until the whole thing being discussed is resolved. If it gets resolved, feel free to dismiss this review. No need to check with me on it!
After discussing this with @addaleax I agree that the code should stay as it is. It is difficult to write a test for this but what we could do is adding a code comment what this actually tests and why it is hard to test. |
I'll update the PR to include some comments then |
This new commit re-formats the comments for linting checks
Co-Authored-By: bewchy <[email protected]>
Landed in 9827858. Thanks for the contribution! 🎉 (If you're interested in other possible contributions to Node.js but don't have a good idea of where to start looking, some ideas are posted at https://www.nodetodo.org/next-steps/.) |
PR-URL: nodejs#24222 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
PR-URL: #24222 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
PR-URL: nodejs#24222 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
PR-URL: #24222 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
PR-URL: #24222 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
When creating a socket, if the file descriptor is not a valid PIPE or
TCP type, createHandle throws an ERR_INVALID_FD_TYPE. This means that
this._handle.open
is guaranteed to succeed and will never return anerror.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes