Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dbb2e6f

Browse filesBrowse files
watildetargos
authored andcommitted
net: check objectMode first and then readble || writable
Co-authored-by: Luigi Pinca <luigipinca@gmail.com> PR-URL: #40344 Fixes: #40336 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: Zijian Liu <lxxyxzj@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com>
1 parent a672be5 commit dbb2e6f
Copy full SHA for dbb2e6f

File tree

Expand file treeCollapse file tree

1 file changed

+15
-14
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-14
lines changed
Open diff view settings
Collapse file

‎lib/net.js‎

Copy file name to clipboardExpand all lines: lib/net.js
+15-14Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -283,20 +283,21 @@ const kSetNoDelay = Symbol('kSetNoDelay');
283283

284284
function Socket(options) {
285285
if (!(this instanceof Socket)) return new Socket(options);
286-
const invalidKeys = [
287-
'objectMode',
288-
'readableObjectMode',
289-
'writableObjectMode',
290-
];
291-
invalidKeys.forEach((invalidKey) => {
292-
if (ObjectKeys(options).includes(invalidKey)) {
293-
throw new ERR_INVALID_ARG_VALUE(
294-
`options.${invalidKey}`,
295-
options[invalidKey],
296-
'is not supported'
297-
);
298-
}
299-
});
286+
if (options.objectMode) {
287+
throw new ERR_INVALID_ARG_VALUE(
288+
'options.objectMode',
289+
options.objectMode,
290+
'is not supported'
291+
);
292+
} else if (options.readableObjectMode || options.writableObjectMode) {
293+
throw new ERR_INVALID_ARG_VALUE(
294+
`options.${
295+
options.readableObjectMode ? 'readableObjectMode' : 'writableObjectMode'
296+
}`,
297+
options.readableObjectMode || options.writableObjectMode,
298+
'is not supported'
299+
);
300+
}
300301

301302
this.connecting = false;
302303
// Problem with this is that users can supply their own handle, that may not

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.