File tree 2 files changed +27
-10
lines changed
2 files changed +27
-10
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ const WriteWrap = process.binding('stream_wrap').WriteWrap;
42
42
const async_id_symbol = process . binding ( 'async_wrap' ) . async_id_symbol ;
43
43
const { newUid, setInitTriggerId } = require ( 'async_hooks' ) ;
44
44
const nextTick = require ( 'internal/process/next_tick' ) . nextTick ;
45
+ const errors = require ( 'internal/errors' ) ;
45
46
46
47
var cluster ;
47
48
var dns ;
@@ -964,8 +965,9 @@ Socket.prototype.connect = function() {
964
965
this . _sockname = null ;
965
966
}
966
967
967
- var pipe = ! ! options . path ;
968
- debug ( 'pipe' , pipe , options . path ) ;
968
+ const path = options . path ;
969
+ var pipe = ! ! path ;
970
+ debug ( 'pipe' , pipe , path ) ;
969
971
970
972
if ( ! this . _handle ) {
971
973
this . _handle = pipe ? new Pipe ( ) : new TCP ( ) ;
@@ -982,7 +984,13 @@ Socket.prototype.connect = function() {
982
984
this . writable = true ;
983
985
984
986
if ( pipe ) {
985
- internalConnect ( this , options . path ) ;
987
+ if ( typeof path !== 'string' ) {
988
+ throw new errors . TypeError ( 'ERR_INVALID_ARG_TYPE' ,
989
+ 'options.path' ,
990
+ 'string' ,
991
+ path ) ;
992
+ }
993
+ internalConnect ( this , path ) ;
986
994
} else {
987
995
lookupAndConnect ( this , options ) ;
988
996
}
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 . expectsError ( {
12
+ code : 'ENOENT' ,
13
+ message : `connect ENOENT ${ fp } `
14
+ } ) ) ;
15
+ }
16
+
17
+ {
18
+ assert . throws (
19
+ ( ) => net . createConnection ( { path : { } } ) ,
20
+ common . expectsError ( { code : 'ERR_INVALID_ARG_TYPE' } )
21
+ ) ;
22
+ }
You can’t perform that action at this time.
0 commit comments