Skip to content

Commit 753f706

Browse files
bewchyBridgeAR
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 c53117e commit 753f706

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

‎lib/net.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,16 @@ function Socket(options){
264264
const{ fd }=options;
265265
leterr;
266266

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

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

0 commit comments

Comments
(0)