From 0c2d1d57e8fdac2c51e08080175d93fb97aaa06f Mon Sep 17 00:00:00 2001 From: Steven Gabarro Date: Wed, 7 Nov 2018 05:54:13 -0500 Subject: [PATCH] net: add comments explaining error check PR-URL: https://github.com/nodejs/node/pull/24222 Reviewed-By: Ruben Bridgewater Reviewed-By: Luigi Pinca --- lib/net.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/net.js b/lib/net.js index 30cad781bfe134..20b0ede7b78b3b 100644 --- a/lib/net.js +++ b/lib/net.js @@ -263,9 +263,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');