Skip to content

Commit

Permalink
net: add comments explaining error check
Browse files Browse the repository at this point in the history
PR-URL: nodejs#24222
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
bewchy authored and kiyomizumia committed Nov 15, 2018
1 parent 9b08a31 commit 5ad8aaf
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,16 @@ 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);

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 opened. This is difficult to test as most
// un-openable fds will throw on `createHandle`
if (err)
throw errnoException(err, 'open');

Expand Down

0 comments on commit 5ad8aaf

Please sign in to comment.