@@ -408,15 +408,24 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
408408
409409 async #refreshTasks( ) : Promise < void > {
410410 const refreshTasks : Promise < boolean > [ ] = [ ] ;
411- if ( this . #refreshEnabled) {
412- refreshTasks . push ( this . #refreshKeyValues( ) ) ;
411+ if ( this . #refreshEnabled || this . #secretRefreshEnabled) {
412+ refreshTasks . push (
413+ this . #refreshKeyValues( )
414+ . then ( keyValueRefreshed => {
415+ // Only refresh secrets if key values didn't change and secret refresh is enabled
416+ // If key values are refreshed, all secret references will be refreshed as well.
417+ if ( ! keyValueRefreshed && this . #secretRefreshEnabled) {
418+ // Returns the refreshSecrets promise directly.
419+ // in a Promise chain, this automatically flattens nested Promises without requiring await.
420+ return this . #refreshSecrets( ) ;
421+ }
422+ return keyValueRefreshed ;
423+ } )
424+ ) ;
413425 }
414426 if ( this . #featureFlagRefreshEnabled) {
415427 refreshTasks . push ( this . #refreshFeatureFlags( ) ) ;
416428 }
417- if ( this . #secretRefreshEnabled) {
418- refreshTasks . push ( this . #refreshSecrets( ) ) ;
419- }
420429
421430 // wait until all tasks are either resolved or rejected
422431 const results = await Promise . allSettled ( refreshTasks ) ;
@@ -579,7 +588,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
579588 */
580589 async #refreshKeyValues( ) : Promise < boolean > {
581590 // if still within refresh interval/backoff, return
582- if ( ! this . #kvRefreshTimer. canRefresh ( ) ) {
591+ if ( this . #kvRefreshTimer === undefined || ! this . #kvRefreshTimer. canRefresh ( ) ) {
583592 return Promise . resolve ( false ) ;
584593 }
585594
@@ -619,7 +628,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
619628 */
620629 async #refreshFeatureFlags( ) : Promise < boolean > {
621630 // if still within refresh interval/backoff, return
622- if ( ! this . #ffRefreshTimer. canRefresh ( ) ) {
631+ if ( this . #ffRefreshInterval === undefined || ! this . #ffRefreshTimer. canRefresh ( ) ) {
623632 return Promise . resolve ( false ) ;
624633 }
625634
@@ -634,7 +643,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
634643
635644 async #refreshSecrets( ) : Promise < boolean > {
636645 // if still within refresh interval/backoff, return
637- if ( ! this . #secretRefreshTimer. canRefresh ( ) ) {
646+ if ( this . #secretRefreshTimer === undefined || ! this . #secretRefreshTimer. canRefresh ( ) ) {
638647 return Promise . resolve ( false ) ;
639648 }
640649
0 commit comments