Add some defensive strategy to command urls in remote help

Fixes microsoft/vscode-remote-release#3612
This commit is contained in:
Alex Ross
2020-09-01 17:03:20 +02:00
parent 8d25a72d9b
commit d87a8cd2a4
@@ -281,7 +281,10 @@ class HelpItemValue {
if (url.authority) {
this._url = this.urlOrCommand;
} else {
this._url = await this.commandService.executeCommand(this.urlOrCommand);
const urlCommand: Promise<string | undefined> = this.commandService.executeCommand(this.urlOrCommand);
// We must be defensive. The command may never return, meaning that no help at all is ever shown!
const emptyString: Promise<string> = new Promise(resolve => setTimeout(() => resolve(''), 500));
this._url = await Promise.race([urlCommand, emptyString]);
}
} else {
this._url = '';
@@ -326,13 +329,13 @@ abstract class HelpItemBase implements IHelpItem {
}
if (this.values.length > 1) {
let actions = await Promise.all(this.values.map(async (value) => {
let actions = (await Promise.all(this.values.map(async (value) => {
return {
label: value.extensionDescription.displayName || value.extensionDescription.identifier.value,
description: await value.url,
extensionDescription: value.extensionDescription
};
}));
}))).filter(item => item.description);
const action = await this.quickInputService.pick(actions, { placeHolder: nls.localize('pickRemoteExtension', "Select url to open") });