@@ -187,16 +187,20 @@ global.FirebaseHelpers = {
187187 let retries = 0 ;
188188 let maxRetries = 5 ;
189189 // We handle 429 errors in a retry loop
190- while ( ( doc === undefined || doc . status === 429 ) && retries < maxRetries ) {
191- doc = await fetch (
192- `https://us-central1-${ getE2eTestProject ( ) } .cloudfunctions.net/${ functioNName } ` ,
193- {
194- method : 'POST' ,
195- body : JSON . stringify ( { data : postData } ) ,
196- headers : { 'Content-Type' : 'application/json' } ,
197- } ,
198- ) ;
199- if ( doc . status === 429 ) {
190+ while ( ( doc === undefined || ( doc && doc . status === 429 ) ) && retries < maxRetries ) {
191+ try {
192+ doc = await fetch (
193+ `https://us-central1-${ getE2eTestProject ( ) } .cloudfunctions.net/${ functioNName } ` ,
194+ {
195+ method : 'POST' ,
196+ body : JSON . stringify ( { data : postData } ) ,
197+ headers : { 'Content-Type' : 'application/json' } ,
198+ } ,
199+ ) ;
200+ } catch ( _error ) {
201+ doc = undefined ;
202+ }
203+ if ( doc && doc . status === 429 ) {
200204 // We have been delayed by concurrency limits or rate limits
201205 // We'll sleep for a little bit then try again.
202206 const delayRequired = 10 ;
@@ -206,7 +210,7 @@ global.FirebaseHelpers = {
206210 }
207211
208212 // did we eventually have success? If not, error.
209- if ( retries === maxRetries && doc . status !== 200 ) {
213+ if ( ! doc || doc . status !== 200 ) {
210214 throw new Error ( 'Unable to execute cloud remote config helper function' ) ;
211215 }
212216 const result = await doc . json ( ) ;
0 commit comments