@@ -26,7 +26,7 @@ const pipes = new Map<string, 'unknown' | 'ready'>();
26
26
27
27
export const onSomePipeReadyCallbacks : ( ( ) => void ) [ ] = [ ] ;
28
28
29
- function watchNamedPipeReady ( namedPipePath : string ) {
29
+ function waitingForNamedPipeServerReady ( namedPipePath : string ) {
30
30
const socket = net . connect ( namedPipePath ) ;
31
31
const start = Date . now ( ) ;
32
32
socket . on ( 'connect' , ( ) => {
@@ -49,6 +49,10 @@ function watchNamedPipeReady(namedPipePath: string) {
49
49
pipes . delete ( namedPipePath ) ;
50
50
socket . end ( ) ;
51
51
} ) ;
52
+ socket . on ( 'timeout' , ( ) => {
53
+ pipes . delete ( namedPipePath ) ;
54
+ socket . end ( ) ;
55
+ } ) ;
52
56
}
53
57
54
58
export function getNamedPipePath ( projectKind : ts . server . ProjectKind . Configured | ts . server . ProjectKind . Inferred , key : number ) {
@@ -68,14 +72,14 @@ export function getReadyNamedPipePaths() {
68
72
}
69
73
else if ( ! pipes . has ( configuredPipe ) ) {
70
74
pipes . set ( configuredPipe , 'unknown' ) ;
71
- watchNamedPipeReady ( configuredPipe ) ;
75
+ waitingForNamedPipeServerReady ( configuredPipe ) ;
72
76
}
73
77
if ( pipes . get ( inferredPipe ) === 'ready' ) {
74
78
inferredPipes . push ( inferredPipe ) ;
75
79
}
76
80
else if ( ! pipes . has ( inferredPipe ) ) {
77
81
pipes . set ( inferredPipe , 'unknown' ) ;
78
- watchNamedPipeReady ( inferredPipe ) ;
82
+ waitingForNamedPipeServerReady ( inferredPipe ) ;
79
83
}
80
84
}
81
85
return {
@@ -104,11 +108,13 @@ export function connect(namedPipePath: string, timeout?: number) {
104
108
pipes . delete ( namedPipePath ) ;
105
109
cleanup ( ) ;
106
110
resolve ( 'error' ) ;
111
+ socket . end ( ) ;
107
112
} ;
108
113
const onTimeout = ( ) => {
109
114
cleanup ( ) ;
110
115
resolve ( 'timeout' ) ;
111
- }
116
+ socket . end ( ) ;
117
+ } ;
112
118
const cleanup = ( ) => {
113
119
socket . off ( 'connect' , onConnect ) ;
114
120
socket . off ( 'error' , onError ) ;
0 commit comments