watcher - do not restart when normal termination (#174709)

This commit is contained in:
Benjamin Pasero
2023-02-17 20:26:42 +01:00
committed by GitHub
parent eee87af252
commit c8e93b654b
2 changed files with 13 additions and 4 deletions

View File

@@ -218,6 +218,10 @@ export abstract class AbstractWatcherClient extends Disposable {
this.onLogMessage({ type: 'error', message: `[File Watcher (${this.options.type})] ${message}` });
}
protected trace(message: string) {
this.onLogMessage({ type: 'trace', message: `[File Watcher (${this.options.type})] ${message}` });
}
override dispose(): void {
// Render the watcher invalid from here

View File

@@ -38,11 +38,16 @@ export class UniversalWatcherClient extends AbstractUniversalWatcherClient {
});
// React on unexpected termination of the watcher process
// We never expect the watcher to terminate by its own,
// so if that happens we want to restart the watcher.
// by listening to the `onDidTerminate` event. We do not
// consider an exit code of `0` as abnormal termination.
onDidTerminate.then(({ reason }) => {
if (reason) {
this.onError(`terminated by itself with code ${reason.code}, signal: ${reason.signal}`);
if (reason?.code === 0) {
this.trace(`terminated by itself with code ${reason.code}, signal: ${reason.signal}`);
} else {
if (reason) {
this.onError(`terminated by itself unexpectedly with code ${reason.code}, signal: ${reason.signal}`);
}
}
});