@@ -22,6 +22,7 @@ import { ExtHostExtensionService } from 'vs/workbench/api/node/extHostExtensionS
2222import { URI } from 'vs/base/common/uri' ;
2323import { promisify } from 'util' ;
2424import { ILogService } from 'vs/platform/log/common/log' ;
25+ import { IExtensionDescription } from 'vs/platform/extensions/common/extensions' ;
2526
2627interface ConnectionResult {
2728 proxy : string ;
@@ -318,14 +319,14 @@ function createPatchedModules(configProvider: ExtHostConfigProvider, resolveProx
318319 override : assign ( { } , http , patches ( http , resolveProxy , { config : 'override' } , certSetting , true ) ) ,
319320 onRequest : assign ( { } , http , patches ( http , resolveProxy , proxySetting , certSetting , true ) ) ,
320321 default : assign ( http , patches ( http , resolveProxy , proxySetting , certSetting , false ) ) // run last
321- } ,
322+ } as Record < string , typeof http > ,
322323 https : {
323324 off : assign ( { } , https , patches ( https , resolveProxy , { config : 'off' } , certSetting , true ) ) ,
324325 on : assign ( { } , https , patches ( https , resolveProxy , { config : 'on' } , certSetting , true ) ) ,
325326 override : assign ( { } , https , patches ( https , resolveProxy , { config : 'override' } , certSetting , true ) ) ,
326327 onRequest : assign ( { } , https , patches ( https , resolveProxy , proxySetting , certSetting , true ) ) ,
327328 default : assign ( https , patches ( https , resolveProxy , proxySetting , certSetting , false ) ) // run last
328- } ,
329+ } as Record < string , typeof https > ,
329330 tls : assign ( tls , tlsPatches ( tls ) )
330331 } ;
331332}
@@ -411,6 +412,7 @@ function tlsPatches(originals: typeof tls) {
411412 }
412413}
413414
415+ const modulesCache = new Map < IExtensionDescription | undefined , { http ?: typeof http , https ?: typeof https } > ( ) ;
414416function configureModuleLoading ( extensionService : ExtHostExtensionService , lookup : ReturnType < typeof createPatchedModules > ) : Promise < void > {
415417 return extensionService . getExtensionPathIndex ( )
416418 . then ( extensionPaths => {
@@ -427,10 +429,18 @@ function configureModuleLoading(extensionService: ExtHostExtensionService, looku
427429
428430 const modules = lookup [ request ] ;
429431 const ext = extensionPaths . findSubstr ( URI . file ( parent . filename ) . fsPath ) ;
430- if ( ext && ext . enableProposedApi ) {
431- return ( modules as any ) [ ( < any > ext ) . proxySupport ] || modules . onRequest ;
432+ let cache = modulesCache . get ( ext ) ;
433+ if ( ! cache ) {
434+ modulesCache . set ( ext , cache = { } ) ;
432435 }
433- return modules . default ;
436+ if ( ! cache [ request ] ) {
437+ let mod = modules . default ;
438+ if ( ext && ext . enableProposedApi ) {
439+ mod = ( modules as any ) [ ( < any > ext ) . proxySupport ] || modules . onRequest ;
440+ }
441+ cache [ request ] = < any > { ...mod } ; // Copy to work around #93167.
442+ }
443+ return cache [ request ] ;
434444 } ;
435445 } ) ;
436446}
0 commit comments