Skip to content

Commit 9233de8

Browse files
authored
Remotes are broken: this.c.makeConnection is not a function (microsoft#182614)
1 parent ebc13c2 commit 9233de8

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

src/vs/workbench/api/common/extHostExtensionService.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import type * as vscode from 'vscode';
2525
import { ExtensionIdentifier, ExtensionIdentifierMap, ExtensionIdentifierSet, IExtensionDescription, IRelaxedExtensionDescription } from 'vs/platform/extensions/common/extensions';
2626
import { VSBuffer } from 'vs/base/common/buffer';
2727
import { ExtensionGlobalMemento, ExtensionMemento } from 'vs/workbench/api/common/extHostMemento';
28-
import { RemoteAuthorityResolverError, ExtensionKind, ExtensionMode, ExtensionRuntime, ResolvedAuthority as ExtHostResolvedAuthority } from 'vs/workbench/api/common/extHostTypes';
28+
import { RemoteAuthorityResolverError, ExtensionKind, ExtensionMode, ExtensionRuntime, ManagedResolvedAuthority as ExtHostManagedResolvedAuthority } from 'vs/workbench/api/common/extHostTypes';
2929
import { ResolvedAuthority, ResolvedOptions, RemoteAuthorityResolverErrorCode, IRemoteConnectionData, getRemoteAuthorityPrefix, TunnelInformation, ManagedRemoteConnection, WebSocketRemoteConnection } from 'vs/platform/remote/common/remoteAuthorityResolver';
3030
import { IInstantiationService, createDecorator } from 'vs/platform/instantiation/common/instantiation';
3131
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
@@ -838,16 +838,11 @@ export abstract class AbstractExtHostExtensionService extends Disposable impleme
838838
authenticationSession: result.authenticationSessionForInitializingExtensions ? { id: result.authenticationSessionForInitializingExtensions.id, providerId: result.authenticationSessionForInitializingExtensions.providerId } : undefined
839839
};
840840

841-
logInfo(`returned ${result instanceof ExtHostResolvedAuthority ? `${result.host}:${result.port}` : 'managed authority'}`);
841+
// extension are not required to return an instance of ResolvedAuthority or ManagedResolvedAuthority, so don't use `instanceof`
842+
logInfo(`returned ${ExtHostManagedResolvedAuthority.isManagedResolvedAuthority(result) ? 'managed authority' : `${result.host}:${result.port}`}`);
842843

843844
let authority: ResolvedAuthority;
844-
if (result instanceof ExtHostResolvedAuthority) {
845-
authority = {
846-
authority: remoteAuthority,
847-
connectTo: new WebSocketRemoteConnection(result.host, result.port),
848-
connectionToken: result.connectionToken
849-
};
850-
} else {
845+
if (ExtHostManagedResolvedAuthority.isManagedResolvedAuthority(result)) {
851846
// The socket factory is identified by the `resolveAttempt`, since that is a number which
852847
// always increments and is unique over all resolve() calls in a workbench session.
853848
const socketFactoryId = resolveAttempt;
@@ -860,6 +855,12 @@ export abstract class AbstractExtHostExtensionService extends Disposable impleme
860855
connectTo: new ManagedRemoteConnection(socketFactoryId),
861856
connectionToken: result.connectionToken
862857
};
858+
} else {
859+
authority = {
860+
authority: remoteAuthority,
861+
connectTo: new WebSocketRemoteConnection(result.host, result.port),
862+
connectionToken: result.connectionToken
863+
};
863864
}
864865

865866
return {

src/vs/workbench/api/common/extHostTypes.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,14 @@ const validateConnectionToken = (connectionToken: string) => {
487487

488488

489489
export class ResolvedAuthority {
490+
public static isResolvedAuthority(resolvedAuthority: any): resolvedAuthority is ResolvedAuthority {
491+
return resolvedAuthority
492+
&& typeof resolvedAuthority === 'object'
493+
&& typeof resolvedAuthority.host === 'string'
494+
&& typeof resolvedAuthority.port === 'number'
495+
&& (resolvedAuthority.connectionToken === undefined || typeof resolvedAuthority.connectionToken === 'string');
496+
}
497+
490498
readonly host: string;
491499
readonly port: number;
492500
readonly connectionToken: string | undefined;
@@ -507,7 +515,16 @@ export class ResolvedAuthority {
507515
}
508516
}
509517

518+
510519
export class ManagedResolvedAuthority {
520+
521+
public static isManagedResolvedAuthority(resolvedAuthority: any): resolvedAuthority is ManagedResolvedAuthority {
522+
return resolvedAuthority
523+
&& typeof resolvedAuthority === 'object'
524+
&& typeof resolvedAuthority.makeConnection === 'function'
525+
&& (resolvedAuthority.connectionToken === undefined || typeof resolvedAuthority.connectionToken === 'string');
526+
}
527+
511528
constructor(public readonly makeConnection: () => Thenable<vscode.ManagedMessagePassing>, public readonly connectionToken?: string) {
512529
if (typeof connectionToken !== 'undefined') {
513530
validateConnectionToken(connectionToken);

0 commit comments

Comments
 (0)