mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
Use an exponential delay for API retries
This commit is contained in:
@@ -730,25 +730,19 @@ describe("Cline", () => {
|
||||
const iterator = cline.attemptApiRequest(0)
|
||||
await iterator.next()
|
||||
|
||||
// Calculate expected delay for first retry
|
||||
const baseDelay = 3 // from requestDelaySeconds
|
||||
|
||||
// Verify countdown messages
|
||||
expect(saySpy).toHaveBeenCalledWith(
|
||||
"api_req_retry_delayed",
|
||||
expect.stringContaining("Retrying in 3 seconds"),
|
||||
undefined,
|
||||
true,
|
||||
)
|
||||
expect(saySpy).toHaveBeenCalledWith(
|
||||
"api_req_retry_delayed",
|
||||
expect.stringContaining("Retrying in 2 seconds"),
|
||||
undefined,
|
||||
true,
|
||||
)
|
||||
expect(saySpy).toHaveBeenCalledWith(
|
||||
"api_req_retry_delayed",
|
||||
expect.stringContaining("Retrying in 1 seconds"),
|
||||
undefined,
|
||||
true,
|
||||
)
|
||||
for (let i = baseDelay; i > 0; i--) {
|
||||
expect(saySpy).toHaveBeenCalledWith(
|
||||
"api_req_retry_delayed",
|
||||
expect.stringContaining(`Retrying in ${i} seconds`),
|
||||
undefined,
|
||||
true,
|
||||
)
|
||||
}
|
||||
|
||||
expect(saySpy).toHaveBeenCalledWith(
|
||||
"api_req_retry_delayed",
|
||||
expect.stringContaining("Retrying now"),
|
||||
@@ -757,12 +751,14 @@ describe("Cline", () => {
|
||||
)
|
||||
|
||||
// Verify delay was called correctly
|
||||
expect(mockDelay).toHaveBeenCalledTimes(3)
|
||||
expect(mockDelay).toHaveBeenCalledTimes(baseDelay)
|
||||
expect(mockDelay).toHaveBeenCalledWith(1000)
|
||||
|
||||
// Verify error message content
|
||||
const errorMessage = saySpy.mock.calls.find((call) => call[1]?.includes(mockError.message))?.[1]
|
||||
expect(errorMessage).toBe(`${mockError.message}\n\nRetrying in 3 seconds...`)
|
||||
expect(errorMessage).toBe(
|
||||
`${mockError.message}\n\nRetry attempt 1\nRetrying in ${baseDelay} seconds...`,
|
||||
)
|
||||
})
|
||||
|
||||
describe("loadContext", () => {
|
||||
|
||||
Reference in New Issue
Block a user