@@ -50,7 +50,6 @@ type PagedSettingSelector = SettingSelector & {
5050} ;
5151
5252const DEFAULT_STARTUP_TIMEOUT = 100 * 1000 ; // 100 seconds in milliseconds
53- const MAX_STARTUP_TIMEOUT = 60 * 60 * 1000 ; // 60 minutes in milliseconds
5453
5554export class AzureAppConfigurationImpl implements AzureAppConfiguration {
5655 /**
@@ -335,8 +334,9 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
335334 async #initialize( ) {
336335 if ( ! this . #isInitialLoadCompleted) {
337336 await this . #inspectFmPackage( ) ;
337+ const retryEnabled = this . #options?. startupOptions ?. retryEnabled ?? false ;
338338 const startTimestamp = Date . now ( ) ;
339- while ( startTimestamp + MAX_STARTUP_TIMEOUT > Date . now ( ) ) {
339+ while ( true ) {
340340 try {
341341 await this . #loadSelectedAndWatchedKeyValues( ) ;
342342 if ( this . #featureFlagEnabled) {
@@ -346,20 +346,21 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
346346 this . #isInitialLoadCompleted = true ;
347347 break ;
348348 } catch ( error ) {
349- const timeElapsed = Date . now ( ) - startTimestamp ;
350- let postAttempts = 0 ;
351- let backoffDuration = getFixedBackoffDuration ( timeElapsed ) ;
352- if ( backoffDuration === undefined ) {
353- postAttempts += 1 ;
354- backoffDuration = calculateDynamicBackoffDuration ( postAttempts ) ;
349+ if ( retryEnabled ) {
350+ const timeElapsed = Date . now ( ) - startTimestamp ;
351+ let postAttempts = 0 ;
352+ let backoffDuration = getFixedBackoffDuration ( timeElapsed ) ;
353+ if ( backoffDuration === undefined ) {
354+ postAttempts += 1 ;
355+ backoffDuration = calculateDynamicBackoffDuration ( postAttempts ) ;
356+ }
357+ await new Promise ( resolve => setTimeout ( resolve , backoffDuration ) ) ;
358+ console . warn ( "Failed to load configuration settings at startup. Retrying..." ) ;
359+ } else {
360+ throw error ;
355361 }
356- await new Promise ( resolve => setTimeout ( resolve , backoffDuration ) ) ;
357- console . warn ( "Failed to load configuration settings at startup. Retrying..." ) ;
358362 }
359363 }
360- if ( ! this . #isInitialLoadCompleted) {
361- throw new Error ( "Load operation exceeded the maximum startup timeout." ) ;
362- }
363364 }
364365 }
365366
0 commit comments