Skip to content

Commit 410dc4e

Browse files
add jittering to backoff
1 parent a085226 commit 410dc4e

File tree

2 files changed

+368860
-61231
lines changed

2 files changed

+368860
-61231
lines changed

code-build.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,11 @@ async function waitForBuildEndTime(
8989
if (errObject) {
9090
//We caught an error in trying to make the AWS api call, and are now checking to see if it was just a rate limiting error
9191
if (errObject.message && errObject.message.search("Rate exceeded") !== -1) {
92-
//We were rate-limited, so add `backOff` seconds to the wait time
93-
let newWait = updateInterval + updateBackOff;
92+
// We were rate-limited, so add backoff with Full Jitter, ref: https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
93+
let jitteredBackOff = Math.floor(
94+
Math.random() * (updateBackOff * 2 ** throttleCount)
95+
);
96+
let newWait = updateInterval + jitteredBackOff;
9497
throttleCount++;
9598

9699
//Sleep before trying again

0 commit comments

Comments
 (0)