-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: throw error to object mode in Socket
Fixes: #40336 PR-URL: #40344 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Zijian Liu <[email protected]> Reviewed-By: Robert Nagy <[email protected]>
- Loading branch information
1 parent
c350c21
commit 4644662
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const net = require('net'); | ||
|
||
{ | ||
const invalidKeys = [ | ||
'objectMode', | ||
'readableObjectMode', | ||
'writableObjectMode', | ||
]; | ||
invalidKeys.forEach((invalidKey) => { | ||
const option = { | ||
...common.localhostIPv4, | ||
[invalidKey]: true | ||
}; | ||
const message = `The property 'options.${invalidKey}' is not supported. Received true`; | ||
|
||
assert.throws(() => { | ||
net.createConnection(option); | ||
}, { | ||
code: 'ERR_INVALID_ARG_VALUE', | ||
name: 'TypeError', | ||
message: new RegExp(message) | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const net = require('net'); | ||
|
||
{ | ||
const invalidKeys = [ | ||
'objectMode', | ||
'readableObjectMode', | ||
'writableObjectMode', | ||
]; | ||
invalidKeys.forEach((invalidKey) => { | ||
const option = { | ||
...common.localhostIPv4, | ||
[invalidKey]: true | ||
}; | ||
const message = `The property 'options.${invalidKey}' is not supported. Received true`; | ||
|
||
assert.throws(() => { | ||
const socket = new net.Socket(option); | ||
socket.connect({ port: 8080 }); | ||
}, { | ||
code: 'ERR_INVALID_ARG_VALUE', | ||
name: 'TypeError', | ||
message: new RegExp(message) | ||
}); | ||
}); | ||
} |