diff --git a/src/vs/base/node/config.ts b/src/vs/base/node/config.ts index 46b7cad421466198cab30de5684b97386b5f6dc7..f4f9301b12c404d4589d4830548ecdf3edefea7a 100644 --- a/src/vs/base/node/config.ts +++ b/src/vs/base/node/config.ts @@ -40,6 +40,7 @@ export interface IConfigOptions { export class ConfigWatcher implements IConfigWatcher, IDisposable { private cache: T; private parseErrors: json.ParseError[]; + private disposed: boolean; private loaded: boolean; private timeoutHandle: number; private disposables: IDisposable[]; @@ -140,6 +141,10 @@ export class ConfigWatcher implements IConfigWatcher, IDisposable { } private watch(path: string): void { + if (this.disposed) { + return; // avoid watchers that will never get disposed by checking for being disposed + } + const watcher = fs.watch(path); watcher.on('change', () => this.onConfigFileChange()); @@ -201,6 +206,7 @@ export class ConfigWatcher implements IConfigWatcher, IDisposable { } public dispose(): void { + this.disposed = true; this.disposables = dispose(this.disposables); } } \ No newline at end of file diff --git a/src/vs/base/test/node/config.test.ts b/src/vs/base/test/node/config.test.ts index e4651c215d11263ac44c4ed0be0c80d8844a4a13..36d83d7bdaec917e19683d65eb889ffbd2833673 100644 --- a/src/vs/base/test/node/config.test.ts +++ b/src/vs/base/test/node/config.test.ts @@ -130,6 +130,8 @@ suite('Config', () => { assert.equal(watcher.getConfig().foo, 'changed'); assert.equal(watcher.getValue('foo'), 'changed'); + watcher.dispose(); + cleanUp(done); }); }, 50); diff --git a/src/vs/platform/configuration/test/node/configurationService.test.ts b/src/vs/platform/configuration/test/node/configurationService.test.ts index a9e0bab1af17f820fe39ecc712cbee650821e90a..662ffa1d2fe1d19b65d4a6557c0a0b9e1f7c40fc 100644 --- a/src/vs/platform/configuration/test/node/configurationService.test.ts +++ b/src/vs/platform/configuration/test/node/configurationService.test.ts @@ -28,7 +28,7 @@ class SettingsTestEnvironmentService extends EnvironmentService { get appSettingsPath(): string { return this.customAppSettingsHome; } } -suite('pasero', () => { +suite('ConfigurationService - Node', () => { function testFile(callback: (path: string, cleanUp: (callback: () => void) => void) => void): void { const id = uuid.generateUuid();