Skip to content

Commit b9626a7

Browse files
MuriloFPdaniel-lxs
andauthored
fix: cap API retry exponential backoff at 10 minutes (RooCodeInc#5171)
Co-authored-by: Daniel Riccio <[email protected]>
1 parent 904e956 commit b9626a7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/core/task/Task.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ import { ApiMessage } from "../task-persistence/apiMessages"
8686
import { getMessagesSinceLastSummary, summarizeConversation } from "../condense"
8787
import { maybeRemoveImageBlocks } from "../../api/transform/image-cleaning"
8888

89+
// Constants
90+
const MAX_EXPONENTIAL_BACKOFF_SECONDS = 600 // 10 minutes
91+
8992
export type ClineEvents = {
9093
message: [{ action: "created" | "updated"; message: ClineMessage }]
9194
taskStarted: []
@@ -1799,7 +1802,10 @@ export class Task extends EventEmitter<ClineEvents> {
17991802
}
18001803

18011804
const baseDelay = requestDelaySeconds || 5
1802-
let exponentialDelay = Math.ceil(baseDelay * Math.pow(2, retryAttempt))
1805+
let exponentialDelay = Math.min(
1806+
Math.ceil(baseDelay * Math.pow(2, retryAttempt)),
1807+
MAX_EXPONENTIAL_BACKOFF_SECONDS,
1808+
)
18031809

18041810
// If the error is a 429, and the error details contain a retry delay, use that delay instead of exponential backoff
18051811
if (error.status === 429) {

0 commit comments

Comments
 (0)