Stop file system watchers on application quit to prevent exit code !== 0 (#7504)

* fix: Dispose the kubeconfig watcher when application quits

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* fix: Dispose the extension watcher when application quits

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

---------

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen authored and Sebastian Malton committed 2023-04-05 13:35:13 -04:00
1 parent 807f98ed1b
commit a3716baaf0
3 files changed
+47 -4

No files matched your search

@@ -98,11 +98,19 @@ export class KubeconfigSyncManager {
@action
protected stopOldSync(filePath: string): void {
if (!this.sources.delete(filePath)) {
// already stopped
const source = this.sources.get(filePath);
// already stopped
if (!source) {
return this.dependencies.logger.debug(`no syncing file/folder to stop`, { filePath });
}
const [, disposer] = source;
disposer();
this.sources.delete(filePath);
this.dependencies.logger.info(`stopping sync of file/folder`, { filePath });
this.dependencies.logger.debug(`${this.sources.size} files/folders watched`, { files: Array.from(this.sources.keys()) });
}