Skip to content

Commit bf33ee7

Browse files
authored
(cherry-pick to 1.79 from main) Handle galleryExtension failure in featuredExtensionService (microsoft#184205)
Handle galleryExtension failure in featuredExtensionService (microsoft#184198) Handle galleryExtension failure
1 parent 7a0d962 commit bf33ee7

File tree

1 file changed

+38
-25
lines changed

1 file changed

+38
-25
lines changed

src/vs/workbench/contrib/welcomeGettingStarted/browser/featuredExtensionService.ts

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
77
import { Disposable } from 'vs/base/common/lifecycle';
8-
import { IExtensionGalleryService, IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
8+
import { IExtensionGalleryService, IExtensionManagementService, IGalleryExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
99
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
1010
import { IProductService } from 'vs/platform/product/common/productService';
1111
import { IFeaturedExtension } from 'vs/base/common/product';
@@ -108,7 +108,12 @@ export class FeaturedExtensionsService extends Disposable implements IFeaturedEx
108108
this.ignoredExtensions.add(extension);
109109
}
110110
else {
111-
const galleryExtension = (await this.galleryService.getExtensions([{ id: extension }], CancellationToken.None))[0];
111+
let galleryExtension: IGalleryExtension | undefined;
112+
try {
113+
galleryExtension = (await this.galleryService.getExtensions([{ id: extension }], CancellationToken.None))[0];
114+
} catch (err) {
115+
continue;
116+
}
112117
if (!await this.extensionManagementService.canInstall(galleryExtension)) {
113118
this.ignoredExtensions.add(extension);
114119
}
@@ -176,32 +181,40 @@ export class FeaturedExtensionsService extends Disposable implements IFeaturedEx
176181

177182
const storageKey = FeaturedExtensionsService.STORAGE_KEY + '.' + extensionId;
178183
this.storageService.remove(storageKey, StorageScope.APPLICATION);
179-
180-
const galleryExtension = (await this.galleryService.getExtensions([{ id: extensionId }], CancellationToken.None))[0];
181184
let metadata: string | undefined;
182-
if (galleryExtension) {
183-
switch (key) {
184-
case FeaturedExtensionMetadataType.Title: {
185-
metadata = galleryExtension.displayName;
186-
break;
187-
}
188-
case FeaturedExtensionMetadataType.Description: {
189-
metadata = galleryExtension.description;
190-
break;
191-
}
192-
case FeaturedExtensionMetadataType.ImagePath: {
193-
metadata = galleryExtension.assets.icon?.uri;
194-
break;
195-
}
196-
}
197185

198-
this.storageService.store(storageKey, JSON.stringify({
199-
title: galleryExtension.displayName,
200-
description: galleryExtension.description,
201-
imagePath: galleryExtension.assets.icon?.uri,
202-
date: new Date().getTime()
203-
}), StorageScope.APPLICATION, StorageTarget.MACHINE);
186+
let galleryExtension: IGalleryExtension | undefined;
187+
try {
188+
galleryExtension = (await this.galleryService.getExtensions([{ id: extensionId }], CancellationToken.None))[0];
189+
} catch (err) {
190+
}
191+
192+
if (!galleryExtension) {
193+
return metadata;
194+
}
195+
196+
switch (key) {
197+
case FeaturedExtensionMetadataType.Title: {
198+
metadata = galleryExtension.displayName;
199+
break;
200+
}
201+
case FeaturedExtensionMetadataType.Description: {
202+
metadata = galleryExtension.description;
203+
break;
204+
}
205+
case FeaturedExtensionMetadataType.ImagePath: {
206+
metadata = galleryExtension.assets.icon?.uri;
207+
break;
208+
}
204209
}
210+
211+
this.storageService.store(storageKey, JSON.stringify({
212+
title: galleryExtension.displayName,
213+
description: galleryExtension.description,
214+
imagePath: galleryExtension.assets.icon?.uri,
215+
date: new Date().getTime()
216+
}), StorageScope.APPLICATION, StorageTarget.MACHINE);
217+
205218
return metadata;
206219
}
207220
}

0 commit comments

Comments
 (0)