Skip to content

Commit 409fe05

Browse files
committed
refactor: extract MAX_EXPONENTIAL_BACKOFF_SECONDS constant
- Replaced magic number 600 with named constant for better maintainability - Constant clearly indicates the 10-minute cap for exponential backoff - Addresses review feedback from PR #5171
1 parent 3c1a46f commit 409fe05

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: []
@@ -1792,7 +1795,10 @@ export class Task extends EventEmitter<ClineEvents> {
17921795
}
17931796

17941797
const baseDelay = requestDelaySeconds || 5
1795-
let exponentialDelay = Math.min(Math.ceil(baseDelay * Math.pow(2, retryAttempt)), 600) // Cap at 10 minutes
1798+
let exponentialDelay = Math.min(
1799+
Math.ceil(baseDelay * Math.pow(2, retryAttempt)),
1800+
MAX_EXPONENTIAL_BACKOFF_SECONDS,
1801+
)
17961802

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

0 commit comments

Comments
 (0)