diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts index 0176cd92e886e..185b43fcfb709 100644 --- a/src/vs/code/electron-main/app.ts +++ b/src/vs/code/electron-main/app.ts @@ -1196,7 +1196,6 @@ export class CodeApplication extends Disposable { private afterWindowOpen(accessor: ServicesAccessor, sharedProcess: SharedProcess): void { const telemetryService = accessor.get(ITelemetryService); - const updateService = accessor.get(IUpdateService); // Observe shared process for errors this.handleSharedProcessErrors(telemetryService, sharedProcess); @@ -1212,11 +1211,6 @@ export class CodeApplication extends Disposable { }); }); - // Initialize update service - if (updateService instanceof Win32UpdateService || updateService instanceof LinuxUpdateService || updateService instanceof DarwinUpdateService) { - updateService.initialize(); - } - // Start to fetch shell environment (if needed) after window has opened // Since this operation can take a long time, we want to warm it up while // the window is opening. diff --git a/src/vs/platform/update/electron-main/abstractUpdateService.ts b/src/vs/platform/update/electron-main/abstractUpdateService.ts index 73fe6e1ab7acf..42bb9cd047cf8 100644 --- a/src/vs/platform/update/electron-main/abstractUpdateService.ts +++ b/src/vs/platform/update/electron-main/abstractUpdateService.ts @@ -8,7 +8,7 @@ import { CancellationToken } from 'vs/base/common/cancellation'; import { Emitter, Event } from 'vs/base/common/event'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService'; -import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService'; +import { ILifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService'; import { ILogService } from 'vs/platform/log/common/log'; import { IProductService } from 'vs/platform/product/common/productService'; import { IRequestService } from 'vs/platform/request/common/request'; @@ -52,14 +52,17 @@ export abstract class AbstractUpdateService implements IUpdateService { @IRequestService protected requestService: IRequestService, @ILogService protected logService: ILogService, @IProductService protected readonly productService: IProductService - ) { } + ) { + lifecycleMainService.when(LifecycleMainPhase.AfterWindowOpen) + .finally(() => this.initialize()); + } /** * This must be called before any other call. This is a performance * optimization, to avoid using extra CPU cycles before first window open. * https://github.com/microsoft/vscode/issues/89784 */ - async initialize(): Promise { + protected async initialize(): Promise { if (!this.environmentMainService.isBuilt) { return; // updates are never enabled when running out of sources } diff --git a/src/vs/platform/update/electron-main/updateService.darwin.ts b/src/vs/platform/update/electron-main/updateService.darwin.ts index c5a8502f8dc4b..8794110bd5a19 100644 --- a/src/vs/platform/update/electron-main/updateService.darwin.ts +++ b/src/vs/platform/update/electron-main/updateService.darwin.ts @@ -38,7 +38,7 @@ export class DarwinUpdateService extends AbstractUpdateService { super(lifecycleMainService, configurationService, environmentMainService, requestService, logService, productService); } - override async initialize(): Promise { + protected override async initialize(): Promise { await super.initialize(); this.onRawError(this.onError, this, this.disposables); this.onRawUpdateAvailable(this.onUpdateAvailable, this, this.disposables); diff --git a/src/vs/platform/update/electron-main/updateService.win32.ts b/src/vs/platform/update/electron-main/updateService.win32.ts index caecd71933412..cadd4a0dd7b09 100644 --- a/src/vs/platform/update/electron-main/updateService.win32.ts +++ b/src/vs/platform/update/electron-main/updateService.win32.ts @@ -71,13 +71,13 @@ export class Win32UpdateService extends AbstractUpdateService { super(lifecycleMainService, configurationService, environmentMainService, requestService, logService, productService); } - override async initialize(): Promise { + protected override async initialize(): Promise { if (this.productService.target === 'user' && await this.nativeHostMainService.isAdmin(undefined)) { this.logService.info('update#ctor - updates are disabled due to running as Admin in user setup'); return; } - super.initialize(); + await super.initialize(); } protected buildUpdateFeedUrl(quality: string): string | undefined {