Skip to content

Commit 588bc01

Browse files
committed
Split up getEnvironment() calls
1 parent 15e410b commit 588bc01

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ export abstract class AbstractRemoteAgentService extends Disposable implements I
4242

4343
abstract getConnection(): IRemoteAgentConnection | null;
4444

45-
getEnvironment(bail?: boolean): Promise<IRemoteAgentEnvironment | null> {
45+
getEnvironment(): Promise<IRemoteAgentEnvironment | null> {
46+
return this.getRawEnvironment().then(undefined, () => null);
47+
}
48+
49+
getRawEnvironment(): Promise<IRemoteAgentEnvironment | null> {
4650
if (!this._environment) {
4751
this._environment = this._withChannel(
4852
async (channel, connection) => {
@@ -53,7 +57,7 @@ export abstract class AbstractRemoteAgentService extends Disposable implements I
5357
null
5458
);
5559
}
56-
return bail ? this._environment : this._environment.then(undefined, () => null);
60+
return this._environment;
5761
}
5862

5963
getDiagnosticInfo(options: IDiagnosticInfoOptions): Promise<IDiagnosticInfo | undefined> {
@@ -170,7 +174,7 @@ class RemoteConnectionFailureNotificationContribution implements IWorkbenchContr
170174
@INotificationService notificationService: INotificationService,
171175
) {
172176
// Let's cover the case where connecting to fetch the remote extension info fails
173-
remoteAgentService.getEnvironment(true)
177+
remoteAgentService.getRawEnvironment()
174178
.then(undefined, err => {
175179
if (!RemoteAuthorityResolverError.isHandled(err)) {
176180
notificationService.error(nls.localize('connectionError', "Failed to connect to the remote extension host server (Error: {0})", err ? err.message : ''));

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@ export interface IRemoteAgentService {
2121
readonly socketFactory: ISocketFactory;
2222

2323
getConnection(): IRemoteAgentConnection | null;
24-
getEnvironment(bail?: boolean): Promise<IRemoteAgentEnvironment | null>;
24+
/**
25+
* Get the remote environment. In case of an error, returns `null`.
26+
*/
27+
getEnvironment(): Promise<IRemoteAgentEnvironment | null>;
28+
/**
29+
* Get the remote environment. Can return an error.
30+
*/
31+
getRawEnvironment(): Promise<IRemoteAgentEnvironment | null>;
2532
getDiagnosticInfo(options: IDiagnosticInfoOptions): Promise<IDiagnosticInfo | undefined>;
2633
disableTelemetry(): Promise<void>;
2734
logTelemetry(eventName: string, data?: ITelemetryData): Promise<void>;

0 commit comments

Comments
 (0)