Skip to content

Commit 732824c

Browse files
committed
Fixing TSServer Restart Happening Twice
Fixes microsoft#27817 **Bug** When triggering a manual TSServer restart, we currently start a new instance than immediatly kill it and start another new instance of the service. This is caused by the current handler for proces crashes not knowing that it should not restart the service for manual restarts. **Fix** Make sure kill doesn't automatically try to start up another instance of the TS Server when we manually restart the server
1 parent 9f99d4e commit 732824c

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

extensions/typescript/src/typescriptServiceClient.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
240240
private firstStart: number;
241241
private lastStart: number;
242242
private numberRestarts: number;
243+
private isRestarting: boolean = false;
244+
243245
private cancellationPipeName: string | null = null;
244246

245247
private requestQueue: RequestQueue;
@@ -305,13 +307,14 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
305307

306308
public restartTsServer(): void {
307309
const start = () => {
308-
this.servicePromise = this.startService();
310+
this.servicePromise = this.startService(true);
309311
return this.servicePromise;
310312
};
311313

312314
if (this.servicePromise) {
313315
this.servicePromise = this.servicePromise.then(cp => {
314316
if (cp) {
317+
this.isRestarting = true;
315318
cp.kill();
316319
}
317320
}).then(start);
@@ -352,15 +355,15 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
352355
return this._onReady.promise;
353356
}
354357

355-
public info(message: string, data?: any): void {
358+
private info(message: string, data?: any): void {
356359
this.logger.info(message, data);
357360
}
358361

359362
public warn(message: string, data?: any): void {
360363
this.logger.warn(message, data);
361364
}
362365

363-
public error(message: string, data?: any): void {
366+
private error(message: string, data?: any): void {
364367
this.logger.error(message, data);
365368
}
366369

@@ -567,7 +570,8 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
567570
if (this.tsServerLogFile) {
568571
this.info(`TSServer log file: ${this.tsServerLogFile}`);
569572
}
570-
this.serviceExited(true);
573+
this.serviceExited(!this.isRestarting);
574+
this.isRestarting = false;
571575
});
572576

573577
this.reader = new Reader<Proto.Response>(

0 commit comments

Comments
 (0)