From 656d727854288f3a6731ff63218387592041e436 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Wed, 21 Oct 2020 15:56:22 -0700 Subject: [PATCH] Skip getting icon if we don't have a server info (#13017) --- .../browser/connectionManagementService.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/sql/workbench/services/connection/browser/connectionManagementService.ts b/src/sql/workbench/services/connection/browser/connectionManagementService.ts index 94d4dc4626..ffeb40596a 100644 --- a/src/sql/workbench/services/connection/browser/connectionManagementService.ts +++ b/src/sql/workbench/services/connection/browser/connectionManagementService.ts @@ -573,8 +573,12 @@ export class ConnectionManagementService extends Disposable implements IConnecti let iconProvider = this._iconProviders.get(connectionManagementInfo.providerId); if (iconProvider) { - let serverInfo: azdata.ServerInfo = this.getServerInfo(connectionProfile.id); - let profile: interfaces.IConnectionProfile = connectionProfile.toIConnectionProfile(); + const serverInfo: azdata.ServerInfo | undefined = this.getServerInfo(connectionProfile.id); + if (!serverInfo) { + this._logService.warn(`Could not find ServerInfo for connection ${connectionProfile.id} when updating icon`); + return; + } + const profile: interfaces.IConnectionProfile = connectionProfile.toIConnectionProfile(); iconProvider.getConnectionIconId(profile, serverInfo).then(iconId => { if (iconId && this._mementoObj && this._mementoContext) { if (!this._mementoObj.CONNECTION_ICON_ID) { @@ -1376,10 +1380,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti if (!profile) { return undefined; } - - let serverInfo = profile.serverInfo; - - return serverInfo; + return profile.serverInfo; } public getConnectionProfileById(profileId: string): interfaces.IConnectionProfile {