4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
6
import { Schemas } from 'vs/base/common/network' ;
7
- import { StopWatch } from 'vs/base/common/stopwatch' ;
8
7
import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
9
8
import { ExtensionKind } from 'vs/platform/environment/common/environment' ;
10
9
import { ExtensionIdentifier , ExtensionType , IExtension , IExtensionDescription } from 'vs/platform/extensions/common/extensions' ;
@@ -16,7 +15,7 @@ import { ILogService } from 'vs/platform/log/common/log';
16
15
import { INotificationService } from 'vs/platform/notification/common/notification' ;
17
16
import { IProductService } from 'vs/platform/product/common/productService' ;
18
17
import { PersistentConnectionEventType } from 'vs/platform/remote/common/remoteAgentConnection' ;
19
- import { IRemoteAuthorityResolverService , RemoteAuthorityResolverError , RemoteAuthorityResolverErrorCode , ResolverResult , getRemoteAuthorityPrefix } from 'vs/platform/remote/common/remoteAuthorityResolver' ;
18
+ import { IRemoteAuthorityResolverService , RemoteAuthorityResolverError , ResolverResult } from 'vs/platform/remote/common/remoteAuthorityResolver' ;
20
19
import { IRemoteExtensionsScannerService } from 'vs/platform/remote/common/remoteExtensionsScanner' ;
21
20
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
22
21
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace' ;
@@ -27,7 +26,6 @@ import { IWebWorkerExtensionHostDataProvider, IWebWorkerExtensionHostInitData, W
27
26
import { FetchFileSystemProvider } from 'vs/workbench/services/extensions/browser/webWorkerFileSystemProvider' ;
28
27
import { AbstractExtensionService , IExtensionHostFactory , ResolvedExtensions , checkEnabledAndProposedAPI } from 'vs/workbench/services/extensions/common/abstractExtensionService' ;
29
28
import { ExtensionHostKind , ExtensionRunningPreference , IExtensionHostKindPicker , extensionHostKindToString , extensionRunningPreferenceToString } from 'vs/workbench/services/extensions/common/extensionHostKind' ;
30
- import { IResolveAuthorityErrorResult } from 'vs/workbench/services/extensions/common/extensionHostProxy' ;
31
29
import { IExtensionManifestPropertiesService } from 'vs/workbench/services/extensions/common/extensionManifestPropertiesService' ;
32
30
import { ExtensionRunningLocation } from 'vs/workbench/services/extensions/common/extensionRunningLocation' ;
33
31
import { ExtensionRunningLocationTracker , filterExtensionDescriptions } from 'vs/workbench/services/extensions/common/extensionRunningLocationTracker' ;
@@ -43,8 +41,6 @@ import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/c
43
41
44
42
export class ExtensionService extends AbstractExtensionService implements IExtensionService {
45
43
46
- private _resolveAuthorityAttempt : number = 0 ;
47
-
48
44
constructor (
49
45
@IInstantiationService instantiationService : IInstantiationService ,
50
46
@INotificationService notificationService : INotificationService ,
@@ -62,7 +58,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
62
58
@IRemoteAgentService remoteAgentService : IRemoteAgentService ,
63
59
@IRemoteExtensionsScannerService remoteExtensionsScannerService : IRemoteExtensionsScannerService ,
64
60
@ILifecycleService lifecycleService : ILifecycleService ,
65
- @IRemoteAuthorityResolverService private readonly _remoteAuthorityResolverService : IRemoteAuthorityResolverService ,
61
+ @IRemoteAuthorityResolverService remoteAuthorityResolverService : IRemoteAuthorityResolverService ,
66
62
@IUserDataInitializationService private readonly _userDataInitializationService : IUserDataInitializationService ,
67
63
@IUserDataProfileService private readonly _userDataProfileService : IUserDataProfileService ,
68
64
@IWorkspaceTrustManagementService private readonly _workspaceTrustManagementService : IWorkspaceTrustManagementService ,
@@ -75,7 +71,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
75
71
( ) => this . _getExtensions ( ) ,
76
72
instantiationService ,
77
73
remoteAgentService ,
78
- _remoteAuthorityResolverService ,
74
+ remoteAuthorityResolverService ,
79
75
extensionEnablementService
80
76
) ;
81
77
super (
@@ -96,7 +92,8 @@ export class ExtensionService extends AbstractExtensionService implements IExten
96
92
logService ,
97
93
remoteAgentService ,
98
94
remoteExtensionsScannerService ,
99
- lifecycleService
95
+ lifecycleService ,
96
+ remoteAuthorityResolverService
100
97
) ;
101
98
102
99
// Initialize installed extensions first and do it only after workbench is ready
@@ -205,93 +202,8 @@ export class ExtensionService extends AbstractExtensionService implements IExten
205
202
}
206
203
}
207
204
208
- // impl
209
-
210
- private async _resolveAuthorityAgain ( ) : Promise < void > {
211
- const remoteAuthority = this . _environmentService . remoteAuthority ;
212
- if ( ! remoteAuthority ) {
213
- return ;
214
- }
215
-
216
- this . _remoteAuthorityResolverService . _clearResolvedAuthority ( remoteAuthority ) ;
217
- try {
218
- const result = await this . _resolveAuthorityWithLogging ( remoteAuthority ) ;
219
- this . _remoteAuthorityResolverService . _setResolvedAuthority ( result . authority , result . options ) ;
220
- } catch ( err ) {
221
- this . _remoteAuthorityResolverService . _setResolvedAuthorityError ( remoteAuthority , err ) ;
222
- }
223
- }
224
-
225
- private async _resolveAuthorityInitial ( remoteAuthority : string ) : Promise < ResolverResult > {
226
- const MAX_ATTEMPTS = 5 ;
227
-
228
- for ( let attempt = 1 ; ; attempt ++ ) {
229
- try {
230
- return this . _resolveAuthorityWithLogging ( remoteAuthority ) ;
231
- } catch ( err ) {
232
- if ( RemoteAuthorityResolverError . isNoResolverFound ( err ) ) {
233
- // There is no point in retrying if there is no resolver found
234
- throw err ;
235
- }
236
-
237
- if ( RemoteAuthorityResolverError . isNotAvailable ( err ) ) {
238
- // The resolver is not available and asked us to not retry
239
- throw err ;
240
- }
241
-
242
- if ( attempt >= MAX_ATTEMPTS ) {
243
- // Too many failed attempts, give up
244
- throw err ;
245
- }
246
- }
247
- }
248
- }
249
-
250
- private async _resolveAuthorityWithLogging ( remoteAuthority : string ) : Promise < ResolverResult > {
251
- const authorityPrefix = getRemoteAuthorityPrefix ( remoteAuthority ) ;
252
- const sw = StopWatch . create ( false ) ;
253
- this . _logService . info ( `Invoking resolveAuthority(${ authorityPrefix } )...` ) ;
254
- try {
255
- performance . mark ( `code/willResolveAuthority/${ authorityPrefix } ` ) ;
256
- const result = await this . _resolveAuthority ( remoteAuthority ) ;
257
- performance . mark ( `code/didResolveAuthorityOK/${ authorityPrefix } ` ) ;
258
- this . _logService . info ( `resolveAuthority(${ authorityPrefix } ) returned '${ result . authority . connectTo } ' after ${ sw . elapsed ( ) } ms` ) ;
259
- return result ;
260
- } catch ( err ) {
261
- performance . mark ( `code/didResolveAuthorityError/${ authorityPrefix } ` ) ;
262
- this . _logService . error ( `resolveAuthority(${ authorityPrefix } ) returned an error after ${ sw . elapsed ( ) } ms` , err ) ;
263
- throw err ;
264
- }
265
- }
266
-
267
- private async _resolveAuthority ( remoteAuthority : string ) : Promise < ResolverResult > {
268
- const localWebWorkerExtensionHosts = this . _getExtensionHostManagers ( ExtensionHostKind . LocalWebWorker ) ;
269
- if ( localWebWorkerExtensionHosts . length === 0 ) {
270
- // no local process extension hosts
271
- throw new Error ( `Cannot resolve authority` ) ;
272
- }
273
-
274
- this . _resolveAuthorityAttempt ++ ;
275
- const results = await Promise . all ( localWebWorkerExtensionHosts . map ( extHost => extHost . resolveAuthority ( remoteAuthority , this . _resolveAuthorityAttempt ) ) ) ;
276
-
277
- let bestErrorResult : IResolveAuthorityErrorResult | null = null ;
278
- for ( const result of results ) {
279
- if ( result . type === 'ok' ) {
280
- return result . value ;
281
- }
282
- if ( ! bestErrorResult ) {
283
- bestErrorResult = result ;
284
- continue ;
285
- }
286
- const bestErrorIsUnknown = ( bestErrorResult . error . code === RemoteAuthorityResolverErrorCode . Unknown ) ;
287
- const errorIsUnknown = ( result . error . code === RemoteAuthorityResolverErrorCode . Unknown ) ;
288
- if ( bestErrorIsUnknown && ! errorIsUnknown ) {
289
- bestErrorResult = result ;
290
- }
291
- }
292
-
293
- // we can only reach this if there is an error
294
- throw new RemoteAuthorityResolverError ( bestErrorResult ! . error . message , bestErrorResult ! . error . code , bestErrorResult ! . error . detail ) ;
205
+ protected async _resolveAuthority ( remoteAuthority : string ) : Promise < ResolverResult > {
206
+ return this . _resolveAuthorityOnExtensionHosts ( ExtensionHostKind . LocalWebWorker , remoteAuthority ) ;
295
207
}
296
208
}
297
209
0 commit comments