Skip to content

Commit c3c12bd

Browse files
HermanBilousHerman Bilous
authored and
Herman Bilous
committed
Use Math.pow for retry delay calculation
1 parent 37728ee commit c3c12bd

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/client.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,8 @@ export function createClient<
464464
connectionAckWaitTimeout = 0,
465465
retryAttempts = 5,
466466
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+
// start with 1s delay at retries === 0
468+
const retryDelay = 1000 * Math.pow(2, retries);
471469
await new Promise((resolve) =>
472470
setTimeout(
473471
resolve,

0 commit comments

Comments
 (0)