Skip to content

Commit

Permalink
Handle errors from Dynamic Debug Configuration providers (#202622)
Browse files Browse the repository at this point in the history
* Handle errors from Dynamic Debug Configuration providers

If a Dynamic Configuration provider, via its method `provideDebugConfigurations`, returns `undefined` or throws an Error, the selector in the Debug Tab is left in a borked state instead of going back to the last selected item. 
This was initially reported in #198798, whose fix handled some cases, but not all. This commit attempts to handle all the remaining cases.

* Use logservice to report error

* Fix build

---------

Co-authored-by: Rob Lourens <[email protected]>
  • Loading branch information
walter-erquinigo and roblourens authored Jul 29, 2024
1 parent c8feac1 commit e3b1073
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/c
import { IFileService } from 'vs/platform/files/common/files';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IJSONContributionRegistry, Extensions as JSONExtensions } from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
import { ILogService } from 'vs/platform/log/common/log';
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
import { Registry } from 'vs/platform/registry/common/platform';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
Expand Down Expand Up @@ -72,7 +73,8 @@ export class ConfigurationManager implements IConfigurationManager {
@IExtensionService private readonly extensionService: IExtensionService,
@IHistoryService private readonly historyService: IHistoryService,
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService,
@IContextKeyService contextKeyService: IContextKeyService
@IContextKeyService contextKeyService: IContextKeyService,
@ILogService private readonly logService: ILogService,
) {
this.configProviders = [];
this.toDispose = [this._onDidChangeConfigurationProviders];
Expand Down Expand Up @@ -257,7 +259,18 @@ export class ConfigurationManager implements IConfigurationManager {
disposables.add(input.onDidHide(() => resolve(undefined)));
});

const nestedPicks = await Promise.all(picks);
let nestedPicks: IDynamicPickItem[][];
try {
// This await invokes the extension providers, which might fail due to several reasons,
// therefore we gate this logic under a try/catch to prevent leaving the Debug Tab
// selector in a borked state.
nestedPicks = await Promise.all(picks);
} catch (err) {
this.logService.error(err);
disposables.dispose();
return;
}

const items = nestedPicks.flat();

input.items = items;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ suite('debugConfigurationManager', () => {
new TestExtensionService(),
new TestHistoryService(),
new UriIdentityService(fileService),
new ContextKeyService(configurationService));
new ContextKeyService(configurationService),
new NullLogService());
});

teardown(() => disposables.dispose());
Expand Down

0 comments on commit e3b1073

Please sign in to comment.