File tree Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -872,6 +872,10 @@ function internalConnect(
872
872
873
873
var err ;
874
874
875
+ if ( typeof address !== 'string' ) {
876
+ throw new TypeError ( 'Invalid address: ' + address ) ;
877
+ }
878
+
875
879
if ( localAddress || localPort ) {
876
880
debug ( 'binding to localAddress: %s and localPort: %d (addressType: %d)' ,
877
881
localAddress , localPort , addressType ) ;
Original file line number Diff line number Diff line change 2
2
const common = require ( '../common' ) ;
3
3
const net = require ( 'net' ) ;
4
4
const assert = require ( 'assert' ) ;
5
- const fp = '/tmp/fadagagsdfgsdf' ;
6
- const c = net . connect ( fp ) ;
7
5
8
- c . on ( 'connect' , common . mustNotCall ( ) ) ;
6
+ {
7
+ const fp = '/tmp/fadagagsdfgsdf' ;
8
+ const c = net . connect ( fp ) ;
9
9
10
- c . on ( 'error' , common . mustCall ( function ( e ) {
11
- assert . strictEqual ( e . code , 'ENOENT' ) ;
12
- assert . strictEqual ( e . message , `connect ENOENT ${ fp } ` ) ;
13
- } ) ) ;
10
+ c . on ( 'connect' , common . mustNotCall ( ) ) ;
11
+ c . on ( 'error' , common . mustCall ( function ( e ) {
12
+ assert . strictEqual ( e . code , 'ENOENT' ) ;
13
+ assert . strictEqual ( e . message , `connect ENOENT ${ fp } ` ) ;
14
+ } ) ) ;
15
+ }
16
+
17
+ {
18
+ try {
19
+ net . createConnection ( { path : { } } ) ;
20
+ throw new Error ( 'UNREACHABLE' ) ;
21
+ } catch ( e ) {
22
+ assert . strictEqual ( e . message , 'Invalid address: [object Object]' ) ;
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments