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(
872872
873873 var err ;
874874
875+ if ( typeof address !== 'string' ) {
876+ throw new TypeError ( 'Invalid address: ' + address ) ;
877+ }
878+
875879 if ( localAddress || localPort ) {
876880 debug ( 'binding to localAddress: %s and localPort: %d (addressType: %d)' ,
877881 localAddress , localPort , addressType ) ;
Original file line number Diff line number Diff line change 22const common = require ( '../common' ) ;
33const net = require ( 'net' ) ;
44const assert = require ( 'assert' ) ;
5- const fp = '/tmp/fadagagsdfgsdf' ;
6- const c = net . connect ( fp ) ;
75
8- c . on ( 'connect' , common . mustNotCall ( ) ) ;
6+ {
7+ const fp = '/tmp/fadagagsdfgsdf' ;
8+ const c = net . connect ( fp ) ;
99
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