File tree Expand file tree Collapse file tree 1 file changed +2
-3
lines changed Expand file tree Collapse file tree 1 file changed +2
-3
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ import { AppConfigurationClient } from "@azure/app-configuration";
55
66const MaxBackoffDuration = 10 * 60 * 1000 ; // 10 minutes in milliseconds
77const MinBackoffDuration = 30 * 1000 ; // 30 seconds in milliseconds
8- const MAX_SAFE_EXPONENTIAL = 30 ; // Used to avoid overflow. bitwise operations in JavaScript are limited to 32 bits. It overflows at 2^31 - 1.
98const JITTER_RATIO = 0.25 ;
109
1110export class ConfigurationClientWrapper {
@@ -36,8 +35,8 @@ export function calculateBackoffDuration(failedAttempts: number) {
3635 }
3736
3837 // exponential: minBackoff * 2 ^ (failedAttempts - 1)
39- const exponential = Math . min ( failedAttempts - 1 , MAX_SAFE_EXPONENTIAL ) ;
40- let calculatedBackoffDuration = MinBackoffDuration * ( 1 << exponential ) ;
38+ // The right shift operator is not used in order to avoid potential overflow. Bitwise operations in JavaScript are limited to 32 bits.
39+ let calculatedBackoffDuration = MinBackoffDuration * Math . pow ( 2 , failedAttempts - 1 ) ;
4140 if ( calculatedBackoffDuration > MaxBackoffDuration ) {
4241 calculatedBackoffDuration = MaxBackoffDuration ;
4342 }
You can’t perform that action at this time.
0 commit comments