@@ -283,7 +283,7 @@ export default class AutoLanguageClient {
283
283
* Use this inside the `startServerProcess` override if the language server is a general executable
284
284
* Also see the `spawnChildNode` method
285
285
*/
286
- protected spawn ( exe : string , args : string [ ] , options : cp . SpawnOptions = { } ) : cp . ChildProcess {
286
+ protected spawn ( exe : string , args : string [ ] , options : cp . SpawnOptions = { } ) : LanguageServerProcess {
287
287
this . logger . debug ( `starting "${ exe } ${ args . join ( ' ' ) } "` ) ;
288
288
return cp . spawn ( exe , args , options ) ;
289
289
}
@@ -292,7 +292,7 @@ export default class AutoLanguageClient {
292
292
* Use this inside the `startServerProcess` override if the language server is a JavaScript file.
293
293
* Also see the `spawn` method
294
294
*/
295
- protected spawnChildNode ( args : string [ ] , options : cp . SpawnOptions = { } ) : cp . ChildProcess {
295
+ protected spawnChildNode ( args : string [ ] , options : cp . SpawnOptions = { } ) : LanguageServerProcess {
296
296
this . logger . debug ( `starting child Node "${ args . join ( ' ' ) } "` ) ;
297
297
options . env = options . env || Object . create ( process . env ) ;
298
298
if ( options . env ) {
@@ -370,8 +370,8 @@ export default class AutoLanguageClient {
370
370
lsProcess . on ( 'error' , ( err ) => this . handleSpawnFailure ( err ) ) ;
371
371
lsProcess . on ( "close" , ( ...args ) => this . handleCloseFailure ( ...args ) ) ;
372
372
lsProcess . on ( 'exit' , ( code , signal ) => this . logger . debug ( `exit: code ${ code } signal ${ signal } ` ) ) ;
373
- lsProcess . stderr . setEncoding ( 'utf8' ) ;
374
- lsProcess . stderr . on ( 'data' , ( chunk : Buffer ) => {
373
+ lsProcess . stderr ? .setEncoding ( 'utf8' ) ;
374
+ lsProcess . stderr ? .on ( 'data' , ( chunk : Buffer ) => {
375
375
const errorString = chunk . toString ( ) ;
376
376
this . handleServerStderr ( errorString , projectPath ) ;
377
377
// Keep the last 5 lines for packages to use in messages
@@ -415,8 +415,13 @@ export default class AutoLanguageClient {
415
415
writer = new rpc . SocketMessageWriter ( this . socket ) ;
416
416
break ;
417
417
case 'stdio' :
418
- reader = new rpc . StreamMessageReader ( lsProcess . stdout ) ;
419
- writer = new rpc . StreamMessageWriter ( lsProcess . stdin ) ;
418
+ if ( lsProcess . stdin !== null && lsProcess . stdout !== null ) {
419
+ reader = new rpc . StreamMessageReader ( lsProcess . stdout ) ;
420
+ writer = new rpc . StreamMessageWriter ( lsProcess . stdin ) ;
421
+ } else {
422
+ this . logger . error ( `The language server process for ${ this . getLanguageName ( ) } does not have a valid stdin and stdout` ) ;
423
+ return Utils . assertUnreachable ( 'stdio' as never )
424
+ }
420
425
break ;
421
426
default :
422
427
return Utils . assertUnreachable ( connectionType ) ;
0 commit comments