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 |
Trott
left a comment
There was a problem hiding this comment.
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 <bewchabbacc@gmail.com>
|
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 <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: #24222 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: nodejs#24222 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: #24222 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: #24222 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
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.openis guaranteed to succeed and will never return anerror.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes