Skip to content

Commit bcf2c07

Browse files
committed
test(opencode): cover capped retry backoff with headers
1 parent 0ba2624 commit bcf2c07

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

packages/opencode/test/session/retry.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ describe("session.retry.delay", () => {
3737
expect(delays).toStrictEqual([2000, 4000, 8000, 16000, 30000, 30000, 30000, 30000, 30000, 30000])
3838
})
3939

40+
test("caps delay at 30 seconds when headers omit retry hints", () => {
41+
const error = apiError({ date: new Date().toUTCString() })
42+
const delays = Array.from({ length: 10 }, (_, index) => SessionRetry.delay(index + 1, error))
43+
expect(delays).toStrictEqual([2000, 4000, 8000, 16000, 30000, 30000, 30000, 30000, 30000, 30000])
44+
})
45+
4046
test("prefers retry-after-ms when shorter than exponential", () => {
4147
const error = apiError({ "retry-after-ms": "1500" })
4248
expect(SessionRetry.delay(4, error)).toBe(1500)

0 commit comments

Comments
 (0)