@@ -129,41 +129,38 @@ export class RemoteConfig implements RemoteConfigType {
129
129
* {@link DEFAULT_FETCH_TIMEOUT_SECONDS}.
130
130
*/
131
131
async fetch ( ) : Promise < void > {
132
- return new Promise ( async ( resolve , reject ) => {
133
- // Aborts the request after the given timeout, causing the fetch call to
134
- // reject with an AbortError.
135
- //
136
- // <p>Aborting after the request completes is a no-op, so we don't need a
137
- // corresponding clearTimeout.
138
- //
139
- // Locating abort logic here because:
140
- // * it uses a developer setting (timeout)
141
- // * it applies to all retries (like curl's max-time arg)
142
- // * it is consistent with the Fetch API's signal input
143
- const abortSignal = new RemoteConfigAbortSignal ( ) ;
144
-
145
- setTimeout ( async ( ) => {
146
- // Note a very low delay, eg < 10ms, can elapse before listeners are initialized.
147
- abortSignal . abort ( ) ;
148
- } , this . settings . fetchTimeoutMillis ) ;
149
-
150
- // Catches *all* errors thrown by client so status can be set consistently.
151
- try {
152
- await this . _client . fetch ( {
153
- cacheMaxAgeMillis : this . settings . minimumFetchIntervalMillis ,
154
- signal : abortSignal
155
- } ) ;
156
-
157
- await this . _storageCache . setLastFetchStatus ( 'success' ) ;
158
- resolve ( ) ;
159
- } catch ( e ) {
160
- const lastFetchStatus = hasErrorCode ( e , ErrorCode . FETCH_THROTTLE )
161
- ? 'throttle'
162
- : 'failure' ;
163
- await this . _storageCache . setLastFetchStatus ( lastFetchStatus ) ;
164
- reject ( e ) ;
165
- }
166
- } ) ;
132
+ // Aborts the request after the given timeout, causing the fetch call to
133
+ // reject with an AbortError.
134
+ //
135
+ // <p>Aborting after the request completes is a no-op, so we don't need a
136
+ // corresponding clearTimeout.
137
+ //
138
+ // Locating abort logic here because:
139
+ // * it uses a developer setting (timeout)
140
+ // * it applies to all retries (like curl's max-time arg)
141
+ // * it is consistent with the Fetch API's signal input
142
+ const abortSignal = new RemoteConfigAbortSignal ( ) ;
143
+
144
+ setTimeout ( async ( ) => {
145
+ // Note a very low delay, eg < 10ms, can elapse before listeners are initialized.
146
+ abortSignal . abort ( ) ;
147
+ } , this . settings . fetchTimeoutMillis ) ;
148
+
149
+ // Catches *all* errors thrown by client so status can be set consistently.
150
+ try {
151
+ await this . _client . fetch ( {
152
+ cacheMaxAgeMillis : this . settings . minimumFetchIntervalMillis ,
153
+ signal : abortSignal
154
+ } ) ;
155
+
156
+ await this . _storageCache . setLastFetchStatus ( 'success' ) ;
157
+ } catch ( e ) {
158
+ const lastFetchStatus = hasErrorCode ( e , ErrorCode . FETCH_THROTTLE )
159
+ ? 'throttle'
160
+ : 'failure' ;
161
+ await this . _storageCache . setLastFetchStatus ( lastFetchStatus ) ;
162
+ throw e ;
163
+ }
167
164
}
168
165
169
166
async fetchAndActivate ( ) : Promise < boolean > {
0 commit comments