File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' graphql-ws ' : patch
3
+ ---
4
+
5
+ Use Math.pow for retry delay calculation
Original file line number Diff line number Diff line change @@ -464,14 +464,11 @@ export function createClient<
464
464
connectionAckWaitTimeout = 0 ,
465
465
retryAttempts = 5 ,
466
466
retryWait = async function randomisedExponentialBackoff ( retries ) {
467
- let retryDelay = 1000 ; // start with 1s delay
468
- for ( let i = 0 ; i < retries ; i ++ ) {
469
- retryDelay *= 2 ;
470
- }
467
+ const retryDelaySeconds = Math . pow ( 2 , retries ) ;
471
468
await new Promise ( ( resolve ) =>
472
469
setTimeout (
473
470
resolve ,
474
- retryDelay +
471
+ retryDelaySeconds * 1000 +
475
472
// add random timeout from 300ms to 3s
476
473
Math . floor ( Math . random ( ) * ( 3000 - 300 ) + 300 ) ,
477
474
) ,
You can’t perform that action at this time.
0 commit comments