Skip to content

Commit 630665f

Browse files
committed
Have a separate call for extension scanning (outside of remote agent environment)
1 parent 1858765 commit 630665f

6 files changed

Lines changed: 47 additions & 17 deletions

File tree

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import { URI } from 'vs/base/common/uri';
77
import { OperatingSystem } from 'vs/base/common/platform';
8-
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
98

109
export interface IRemoteAgentEnvironment {
1110
pid: number;
@@ -18,7 +17,6 @@ export interface IRemoteAgentEnvironment {
1817
globalStorageHome: URI;
1918
workspaceStorageHome: URI;
2019
userHome: URI;
21-
extensions: IExtensionDescription[];
2220
os: OperatingSystem;
2321
}
2422

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,13 @@ export class ExtensionService extends AbstractExtensionService implements IExten
111111

112112
protected async _scanAndHandleExtensions(): Promise<void> {
113113
// fetch the remote environment
114-
let [localExtensions, remoteEnv] = await Promise.all([
114+
let [localExtensions, remoteEnv, remoteExtensions] = await Promise.all([
115115
this._webExtensionsScannerService.scanExtensions().then(extensions => extensions.map(parseScannedExtension)),
116-
this._remoteAgentService.getEnvironment()
116+
this._remoteAgentService.getEnvironment(),
117+
this._remoteAgentService.scanExtensions()
117118
]);
118119
localExtensions = this._checkEnabledAndProposedAPI(localExtensions);
119-
let remoteExtensions = remoteEnv ? this._checkEnabledAndProposedAPI(remoteEnv.extensions) : [];
120+
remoteExtensions = this._checkEnabledAndProposedAPI(remoteExtensions);
120121

121122
const remoteAgentConnection = this._remoteAgentService.getConnection();
122123
this._runningLocation = _determineRunningLocation(this._productService, this._configService, localExtensions, remoteExtensions, Boolean(remoteEnv && remoteAgentConnection));

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
500500

501501
const localExtensions = this._checkEnabledAndProposedAPI(await this._scanAllLocalExtensions());
502502
let remoteEnv: IRemoteAgentEnvironment | null = null;
503+
let remoteExtensions: IExtensionDescription[] = [];
503504

504505
if (remoteAuthority) {
505506
let resolverResult: ResolverResult;
@@ -538,7 +539,11 @@ export class ExtensionService extends AbstractExtensionService implements IExten
538539
}
539540

540541
// fetch the remote environment
541-
remoteEnv = await this._remoteAgentService.getEnvironment();
542+
[remoteEnv, remoteExtensions] = await Promise.all([
543+
this._remoteAgentService.getEnvironment(),
544+
this._remoteAgentService.scanExtensions()
545+
]);
546+
remoteExtensions = this._checkEnabledAndProposedAPI(remoteExtensions);
542547

543548
if (!remoteEnv) {
544549
this._notificationService.notify({ severity: Severity.Error, message: nls.localize('getEnvironmentFailure', "Could not fetch remote environment") });
@@ -551,9 +556,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
551556
await this._startLocalExtensionHost(localExtensions, remoteAuthority, remoteEnv);
552557
}
553558

554-
private async _startLocalExtensionHost(localExtensions: IExtensionDescription[], remoteAuthority: string | undefined = undefined, remoteEnv: IRemoteAgentEnvironment | null = null): Promise<void> {
555-
556-
let remoteExtensions = remoteEnv ? this._checkEnabledAndProposedAPI(remoteEnv.extensions) : [];
559+
private async _startLocalExtensionHost(localExtensions: IExtensionDescription[], remoteAuthority: string | undefined = undefined, remoteEnv: IRemoteAgentEnvironment | null = null, remoteExtensions: IExtensionDescription[] = []): Promise<void> {
557560

558561
this._runningLocation = _determineRunningLocation(this._productService, this._configurationService, localExtensions, remoteExtensions, Boolean(remoteAuthority), this._enableLocalWebWorker);
559562

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { Emitter } from 'vs/base/common/event';
2222
import { ISignService } from 'vs/platform/sign/common/sign';
2323
import { ILogService } from 'vs/platform/log/common/log';
2424
import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
25+
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
2526

2627
export abstract class AbstractRemoteAgentService extends Disposable implements IRemoteAgentService {
2728

@@ -50,7 +51,7 @@ export abstract class AbstractRemoteAgentService extends Disposable implements I
5051
if (!this._environment) {
5152
this._environment = this._withChannel(
5253
async (channel, connection) => {
53-
const env = await RemoteExtensionEnvironmentChannelClient.getEnvironmentData(channel, connection.remoteAuthority, this._environmentService.extensionDevelopmentLocationURI);
54+
const env = await RemoteExtensionEnvironmentChannelClient.getEnvironmentData(channel, connection.remoteAuthority);
5455
this._remoteAuthorityResolverService._setAuthorityConnectionToken(connection.remoteAuthority, env.connectionToken);
5556
return env;
5657
},
@@ -60,6 +61,13 @@ export abstract class AbstractRemoteAgentService extends Disposable implements I
6061
return this._environment;
6162
}
6263

64+
scanExtensions(skipExtensions: ExtensionIdentifier[] = []): Promise<IExtensionDescription[]> {
65+
return this._withChannel(
66+
(channel, connection) => RemoteExtensionEnvironmentChannelClient.scanExtensions(channel, connection.remoteAuthority, this._environmentService.extensionDevelopmentLocationURI, skipExtensions),
67+
[]
68+
).then(undefined, () => []);
69+
}
70+
6371
getDiagnosticInfo(options: IDiagnosticInfoOptions): Promise<IDiagnosticInfo | undefined> {
6472
return this._withChannel(
6573
channel => RemoteExtensionEnvironmentChannelClient.getDiagnosticInfo(channel, options),

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

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,20 @@
66
import * as platform from 'vs/base/common/platform';
77
import { URI, UriComponents } from 'vs/base/common/uri';
88
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
9-
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
9+
import { IExtensionDescription, ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
1010
import { IRemoteAgentEnvironment } from 'vs/platform/remote/common/remoteAgentEnvironment';
1111
import { IDiagnosticInfoOptions, IDiagnosticInfo } from 'vs/platform/diagnostics/common/diagnostics';
1212
import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
1313

1414
export interface IGetEnvironmentDataArguments {
15+
remoteAuthority: string;
16+
}
17+
18+
export interface IScanExtensionsArguments {
1519
language: string;
1620
remoteAuthority: string;
1721
extensionDevelopmentPath: UriComponents[] | undefined;
22+
skipExtensions: ExtensionIdentifier[];
1823
}
1924

2025
export interface IRemoteAgentEnvironmentDTO {
@@ -28,17 +33,14 @@ export interface IRemoteAgentEnvironmentDTO {
2833
globalStorageHome: UriComponents;
2934
workspaceStorageHome: UriComponents;
3035
userHome: UriComponents;
31-
extensions: IExtensionDescription[];
3236
os: platform.OperatingSystem;
3337
}
3438

3539
export class RemoteExtensionEnvironmentChannelClient {
3640

37-
static async getEnvironmentData(channel: IChannel, remoteAuthority: string, extensionDevelopmentPath?: URI[]): Promise<IRemoteAgentEnvironment> {
41+
static async getEnvironmentData(channel: IChannel, remoteAuthority: string): Promise<IRemoteAgentEnvironment> {
3842
const args: IGetEnvironmentDataArguments = {
39-
language: platform.language,
40-
remoteAuthority,
41-
extensionDevelopmentPath
43+
remoteAuthority
4244
};
4345

4446
const data = await channel.call<IRemoteAgentEnvironmentDTO>('getEnvironmentData', args);
@@ -54,11 +56,24 @@ export class RemoteExtensionEnvironmentChannelClient {
5456
globalStorageHome: URI.revive(data.globalStorageHome),
5557
workspaceStorageHome: URI.revive(data.workspaceStorageHome),
5658
userHome: URI.revive(data.userHome),
57-
extensions: data.extensions.map(ext => { (<any>ext).extensionLocation = URI.revive(ext.extensionLocation); return ext; }),
5859
os: data.os
5960
};
6061
}
6162

63+
static async scanExtensions(channel: IChannel, remoteAuthority: string, extensionDevelopmentPath: URI[] | undefined, skipExtensions: ExtensionIdentifier[]): Promise<IExtensionDescription[]> {
64+
const args: IScanExtensionsArguments = {
65+
language: platform.language,
66+
remoteAuthority,
67+
extensionDevelopmentPath,
68+
skipExtensions
69+
};
70+
71+
const extensions = await channel.call<IExtensionDescription[]>('scanExtensions', args);
72+
extensions.forEach(ext => { (<any>ext).extensionLocation = URI.revive(ext.extensionLocation); });
73+
74+
return extensions;
75+
}
76+
6277
static getDiagnosticInfo(channel: IChannel, options: IDiagnosticInfoOptions): Promise<IDiagnosticInfo> {
6378
return channel.call<IDiagnosticInfo>('getDiagnosticInfo', options);
6479
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { IDiagnosticInfoOptions, IDiagnosticInfo } from 'vs/platform/diagnostics
1010
import { Event } from 'vs/base/common/event';
1111
import { PersistenConnectionEvent as PersistentConnectionEvent, ISocketFactory } from 'vs/platform/remote/common/remoteAgentConnection';
1212
import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
13+
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
1314

1415
export const RemoteExtensionLogFileName = 'remoteagent';
1516

@@ -29,6 +30,10 @@ export interface IRemoteAgentService {
2930
* Get the remote environment. Can return an error.
3031
*/
3132
getRawEnvironment(): Promise<IRemoteAgentEnvironment | null>;
33+
/**
34+
* Scan remote extensions.
35+
*/
36+
scanExtensions(skipExtensions?: ExtensionIdentifier[]): Promise<IExtensionDescription[]>;
3237
getDiagnosticInfo(options: IDiagnosticInfoOptions): Promise<IDiagnosticInfo | undefined>;
3338
disableTelemetry(): Promise<void>;
3439
logTelemetry(eventName: string, data?: ITelemetryData): Promise<void>;

0 commit comments

Comments
 (0)