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";
5
5
6
6
const MaxBackoffDuration = 10 * 60 * 1000 ; // 10 minutes in milliseconds
7
7
const 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.
9
8
const JITTER_RATIO = 0.25 ;
10
9
11
10
export class ConfigurationClientWrapper {
@@ -36,8 +35,8 @@ export function calculateBackoffDuration(failedAttempts: number) {
36
35
}
37
36
38
37
// 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 ) ;
41
40
if ( calculatedBackoffDuration > MaxBackoffDuration ) {
42
41
calculatedBackoffDuration = MaxBackoffDuration ;
43
42
}
You can’t perform that action at this time.
0 commit comments