Skip to content
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

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
net: add comments on unreachable error check
  • Loading branch information
bewchy authored Nov 13, 2018
commit 4899951ff0c7458a11adc7230be110edf2fb0c58
10 changes: 9 additions & 1 deletion lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,17 @@ function Socket(options) {
const { fd } = options;
let err;

// createHandle will throw ERR_INVALID_FD_TYPE if `fd` is not
// a valid `PIPE` or `TCP` descriptor
this._handle = createHandle(fd, false);

this._handle.open(fd);
err = this._handle.open(fd);

// While difficult to fabricate, in some architectures, `open` may return an error
// code for valid file descriptors which cannot be openned
// This is difficult to test as most un-openable fds will throw on `createHandle`
if (err)
throw errnoException(err, 'open');

this[async_id_symbol] = this._handle.getAsyncId();
// options.fd can be string (since it is user-defined),
Expand Down