Skip to content

Commit 80e3dec

Browse files
committed
net: throw error to given objectMode in connection
Fixes: #40336
1 parent 87da53c commit 80e3dec

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lib/net.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ function connect(...args) {
194194
const normalized = normalizeArgs(args);
195195
const options = normalized[0];
196196
debug('createConnection', normalized);
197+
if (options.objectMode) {
198+
throw new ERR_INVALID_ARG_VALUE('options.objectMode', options.objectMode, 'is not supported');
199+
}
197200
const socket = new Socket(options);
198201

199202
if (options.timeout) {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
const assert = require('assert');
3+
const net = require('net');
4+
5+
{
6+
const ArgValueInvalidError = {
7+
code: 'ERR_INVALID_ARG_VALUE',
8+
name: 'TypeError'
9+
};
10+
11+
const option = {objectMode: true};
12+
13+
assert.throws(() => {
14+
net.createConnection(option);
15+
}, {
16+
code: 'ERR_INVALID_ARG_VALUE',
17+
name: 'TypeError',
18+
message: /The property 'options.objectMode' is not supported. Received true/
19+
});
20+
}

0 commit comments

Comments
 (0)