@@ -42,6 +42,22 @@ export class ApiModel {
4242 }
4343
4444 async getConfig ( proxyPort ?: number ) {
45+ // Wait for each async part in parallel:
46+ const [
47+ systemProxy ,
48+ dnsServers
49+ ] = await Promise . all ( [
50+ withFallback (
51+ ( ) => getSystemProxy ( ) ,
52+ 2000 ,
53+ undefined
54+ ) ,
55+
56+ proxyPort
57+ ? await this . getDnsServers ( proxyPort )
58+ : [ ]
59+ ] )
60+
4561 return {
4662 certificatePath : this . config . https . certPath ,
4763 certificateContent : this . config . https . certContent ,
@@ -52,11 +68,8 @@ export class ApiModel {
5268 certificateFingerprint : generateSPKIFingerprint ( this . config . https . certContent ) ,
5369
5470 networkInterfaces : this . getNetworkInterfaces ( ) ,
55- systemProxy : await withFallback ( ( ) => getSystemProxy ( ) , 2000 , undefined ) ,
56-
57- dnsServers : proxyPort
58- ? await this . getDnsServers ( proxyPort )
59- : [ ] ,
71+ systemProxy,
72+ dnsServers,
6073
6174 ruleParameterKeys : this . getRuleParamKeys ( )
6275 } ;
@@ -88,20 +101,33 @@ export class ApiModel {
88101 } = { } ) {
89102 const interceptor = this . interceptors [ id ] ;
90103
91- return {
92- id : interceptor . id ,
93- version : interceptor . version ,
94- metadata : options . metadataType
95- ? await this . getInterceptorMetadata ( id , options . metadataType )
104+ // Wait for each async part in parallel:
105+ const [
106+ metadata ,
107+ isActivable ,
108+ isActive
109+ ] = await Promise . all ( [
110+ options . metadataType
111+ ? this . getInterceptorMetadata ( id , options . metadataType )
96112 : undefined ,
97- isActivable : await withFallback (
113+
114+ withFallback (
98115 async ( ) => interceptor . isActivable ( ) ,
99116 interceptor . activableTimeout || INTERCEPTOR_TIMEOUT ,
100117 false
101118 ) ,
102- isActive : options . proxyPort
103- ? await this . isInterceptorActive ( id , options . proxyPort )
119+
120+ options . proxyPort
121+ ? this . isInterceptorActive ( id , options . proxyPort )
104122 : undefined
123+ ] )
124+
125+ return {
126+ id : interceptor . id ,
127+ version : interceptor . version ,
128+ metadata,
129+ isActivable,
130+ isActive
105131 } ;
106132 }
107133
0 commit comments