Skip to content

Commit 0c2d1d5

Browse files
bewchycodebytere
authored andcommitted
net: add comments explaining error check
PR-URL: #24222 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 2d0105c commit 0c2d1d5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/net.js

+7
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,16 @@ function Socket(options) {
263263
const { fd } = options;
264264
let err;
265265

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

268270
err = this._handle.open(fd);
271+
272+
// While difficult to fabricate, in some architectures
273+
// `open` may return an error code for valid file descriptors
274+
// which cannot be opened. This is difficult to test as most
275+
// un-openable fds will throw on `createHandle`
269276
if (err)
270277
throw errnoException(err, 'open');
271278

0 commit comments

Comments
 (0)