From e8f4239a6f73655b8dc10b0ace0c36fc6a55f4cf Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Thu, 27 Mar 2025 11:36:33 +0100 Subject: [PATCH] add logging for extension auto updates (#244842) --- .../browser/extensionsWorkbenchService.ts | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts b/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts index 150908a60ae..bcf99d677c2 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts @@ -1065,13 +1065,13 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension } if (e.affectsConfiguration(AutoCheckUpdatesConfigurationKey)) { if (this.isAutoCheckUpdatesEnabled()) { - this.checkForUpdates(); + this.checkForUpdates(`Enabled auto check updates`); } } })); this._register(this.extensionEnablementService.onEnablementChanged(platformExtensions => { if (this.getAutoUpdateValue() === 'onlyEnabledExtensions' && platformExtensions.some(e => this.extensionEnablementService.isEnabled(e))) { - this.checkForUpdates(); + this.checkForUpdates('Extension enablement changed'); } })); this._register(Event.debounce(this.onChange, () => undefined, 100)(() => this.hasOutdatedExtensionsContextKey.set(this.outdated.length > 0))); @@ -1082,14 +1082,14 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension comment: 'Report when update check is triggered on product update'; }>('extensions:updatecheckonproductupdate'); if (this.isAutoCheckUpdatesEnabled()) { - this.checkForUpdates(); + this.checkForUpdates('Product update'); } } })); this._register(this.allowedExtensionsService.onDidChangeAllowedExtensionsConfigValue(() => { if (this.isAutoCheckUpdatesEnabled()) { - this.checkForUpdates(); + this.checkForUpdates('Allowed extensions changed'); } })); @@ -1827,7 +1827,12 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension return ExtensionState.Uninstalled; } - async checkForUpdates(onlyBuiltin?: boolean): Promise { + async checkForUpdates(reason?: string, onlyBuiltin?: boolean): Promise { + if (reason) { + this.logService.info(`[Extensions]: Checking for updates. Reason: ${reason}`); + } else { + this.logService.trace(`[Extensions]: Checking for updates`); + } if (!this.galleryService.isEnabled()) { return; } @@ -1872,6 +1877,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension this.telemetryService.publicLog2('galleryService:checkingForUpdates', { count: infos.length, }); + this.logService.trace(`Checking updates for extensions`, infos.map(e => e.id).join(', ')); const galleryExtensions = await this.galleryService.getExtensions(infos, { targetPlatform, compatible: true, productVersion: this.getProductVersion(), preferResourceApi: true }, CancellationToken.None); if (galleryExtensions.length) { await this.syncInstalledExtensionsWithGallery(galleryExtensions); @@ -1963,6 +1969,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension } await Promise.allSettled(extensions.map(extensions => extensions.syncInstalledExtensionsWithGallery(gallery, this.getProductVersion()))); if (this.outdated.length) { + this.logService.info(`Auto updating outdated extensions.`, this.outdated.map(e => e.identifier.id).join(', ')); this.eventuallyAutoUpdateExtensions(); } } @@ -1994,7 +2001,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension } private async autoUpdateBuiltinExtensions(): Promise { - await this.checkForUpdates(true); + await this.checkForUpdates(undefined, true); const toUpdate = this.outdated.filter(e => e.isBuiltin); await Promises.settled(toUpdate.map(e => this.install(e, e.local?.preRelease ? { installPreReleaseVersion: true } : undefined))); } @@ -2018,9 +2025,11 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension const toUpdate: IExtension[] = []; for (const extension of this.outdated) { if (!this.shouldAutoUpdateExtension(extension)) { + this.logService.info('Auto update disabled for extension', extension.identifier.id); continue; } if (await this.shouldRequireConsentToUpdate(extension)) { + this.logService.info('Auto update consent required for extension', extension.identifier.id); continue; } toUpdate.push(extension); @@ -2031,7 +2040,10 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension } const productVersion = this.getProductVersion(); - await Promises.settled(toUpdate.map(e => this.install(e, e.local?.preRelease ? { installPreReleaseVersion: true, productVersion } : { productVersion }))); + await Promises.settled(toUpdate.map(e => { + this.logService.info('Auto updating extension', e.identifier.id); + return this.install(e, e.local?.preRelease ? { installPreReleaseVersion: true, productVersion } : { productVersion }); + })); } private getProductVersion(): IProductVersion {