From c8e93b654b4e9ef28dfd0bb50518a45ba5a2468c Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Fri, 17 Feb 2023 20:26:42 +0100 Subject: [PATCH] watcher - do not restart when normal termination (#174709) --- src/vs/platform/files/common/watcher.ts | 4 ++++ .../files/electron-sandbox/watcherClient.ts | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/vs/platform/files/common/watcher.ts b/src/vs/platform/files/common/watcher.ts index 6300880a913..45d34691634 100644 --- a/src/vs/platform/files/common/watcher.ts +++ b/src/vs/platform/files/common/watcher.ts @@ -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 diff --git a/src/vs/workbench/services/files/electron-sandbox/watcherClient.ts b/src/vs/workbench/services/files/electron-sandbox/watcherClient.ts index 3afaadd1cba..961c413d0cd 100644 --- a/src/vs/workbench/services/files/electron-sandbox/watcherClient.ts +++ b/src/vs/workbench/services/files/electron-sandbox/watcherClient.ts @@ -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}`); + } } });