Skip to content

Commit d3da6f4

Browse files
committed
Remote: seeing an error message when not having remote extension installed. Fixes microsoft#91526
1 parent c2d241d commit d3da6f4

3 files changed

Lines changed: 16 additions & 20 deletions

File tree

src/vs/platform/remote/common/remoteAuthorityResolver.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,33 @@ export enum RemoteAuthorityResolverErrorCode {
4040

4141
export class RemoteAuthorityResolverError extends Error {
4242

43-
public static isHandledNotAvailable(err: any): boolean {
44-
if (err instanceof RemoteAuthorityResolverError) {
45-
if (err._code === RemoteAuthorityResolverErrorCode.NotAvailable && err._detail === true) {
46-
return true;
47-
}
48-
}
49-
50-
return this.isTemporarilyNotAvailable(err);
51-
}
52-
5343
public static isTemporarilyNotAvailable(err: any): boolean {
5444
return (err instanceof RemoteAuthorityResolverError) && err._code === RemoteAuthorityResolverErrorCode.TemporarilyNotAvailable;
5545
}
5646

57-
public static isNoResolverFound(err: any): boolean {
47+
public static isNoResolverFound(err: any): err is RemoteAuthorityResolverError {
5848
return (err instanceof RemoteAuthorityResolverError) && err._code === RemoteAuthorityResolverErrorCode.NoResolverFound;
5949
}
6050

51+
public static isHandled(err: any): boolean {
52+
return (err instanceof RemoteAuthorityResolverError) && err.isHandled;
53+
}
54+
6155
public readonly _message: string | undefined;
6256
public readonly _code: RemoteAuthorityResolverErrorCode;
6357
public readonly _detail: any;
6458

59+
public isHandled: boolean;
60+
6561
constructor(message?: string, code: RemoteAuthorityResolverErrorCode = RemoteAuthorityResolverErrorCode.Unknown, detail?: any) {
6662
super(message);
6763

6864
this._message = message;
6965
this._code = code;
7066
this._detail = detail;
7167

68+
this.isHandled = (code === RemoteAuthorityResolverErrorCode.NotAvailable) && detail === true;
69+
7270
// workaround when extending builtin objects and when compiling to ES5, see:
7371
// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
7472
if (typeof (<any>Object).setPrototypeOf === 'function') {

src/vs/workbench/services/extensions/electron-browser/extensionService.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -459,16 +459,13 @@ export class ExtensionService extends AbstractExtensionService implements IExten
459459
} catch (err) {
460460
const remoteName = getRemoteName(remoteAuthority);
461461
if (RemoteAuthorityResolverError.isNoResolverFound(err)) {
462-
this._handleNoResolverFound(remoteName, allExtensions);
462+
err.isHandled = await this._handleNoResolverFound(remoteName, allExtensions);
463463
} else {
464464
console.log(err);
465-
if (RemoteAuthorityResolverError.isHandledNotAvailable(err)) {
466-
console.log(`Not showing a notification for the error`);
467-
} else {
468-
this._notificationService.notify({ severity: Severity.Error, message: nls.localize('resolveAuthorityFailure', "Resolving the authority `{0}` failed", remoteName) });
465+
if (RemoteAuthorityResolverError.isHandled(err)) {
466+
console.log(`Error handled: Not showing a notification for the error`);
469467
}
470468
}
471-
472469
this._remoteAuthorityResolverService.setResolvedAuthorityError(remoteAuthority, err);
473470

474471
// Proceed with the local extension host
@@ -584,10 +581,10 @@ export class ExtensionService extends AbstractExtensionService implements IExten
584581
}
585582
}
586583

587-
private async _handleNoResolverFound(remoteName: string, allExtensions: IExtensionDescription[]): Promise<void> {
584+
private async _handleNoResolverFound(remoteName: string, allExtensions: IExtensionDescription[]): Promise<boolean> {
588585
const recommendation = this._productService.remoteExtensionTips?.[remoteName];
589586
if (!recommendation) {
590-
return;
587+
return false;
591588
}
592589
const sendTelemetry = (userReaction: 'install' | 'enable' | 'cancel') => {
593590
/* __GDPR__
@@ -641,6 +638,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
641638
);
642639

643640
}
641+
return true;
644642

645643
}
646644
}

src/vs/workbench/services/remote/common/abstractRemoteAgentService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class RemoteConnectionFailureNotificationContribution implements IWorkbenchContr
164164
// Let's cover the case where connecting to fetch the remote extension info fails
165165
remoteAgentService.getEnvironment(true)
166166
.then(undefined, err => {
167-
if (!RemoteAuthorityResolverError.isHandledNotAvailable(err)) {
167+
if (!RemoteAuthorityResolverError.isHandled(err)) {
168168
notificationService.error(nls.localize('connectionError', "Failed to connect to the remote extension host server (Error: {0})", err ? err.message : ''));
169169
}
170170
});

0 commit comments

Comments
 (0)