From f57010909435d6bfa63398215575fcb185269c14 Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Fri, 8 Oct 2021 14:16:56 +0900 Subject: [PATCH] net: check if option is undefined PR-URL: https://github.com/nodejs/node/pull/40344 Fixes: https://github.com/nodejs/node/issues/40336 Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Minwoo Jung Reviewed-By: Zijian Liu Reviewed-By: Robert Nagy --- lib/net.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/net.js b/lib/net.js index c367eb4181c85c..41ff284e1ec027 100644 --- a/lib/net.js +++ b/lib/net.js @@ -282,13 +282,13 @@ const kSetNoDelay = Symbol('kSetNoDelay'); function Socket(options) { if (!(this instanceof Socket)) return new Socket(options); - if (options.objectMode) { + if (options?.objectMode) { throw new ERR_INVALID_ARG_VALUE( 'options.objectMode', options.objectMode, 'is not supported' ); - } else if (options.readableObjectMode || options.writableObjectMode) { + } else if (options?.readableObjectMode || options?.writableObjectMode) { throw new ERR_INVALID_ARG_VALUE( `options.${ options.readableObjectMode ? 'readableObjectMode' : 'writableObjectMode'