quak backup retries failed requests for longer (closes #165)
check / check (push) Successful in 4m16s
check / check (push) Successful in 4m16s
src/retry.ts exports UNATTENDED_RETRY_OPTIONS beside the unchanged default: 10 attempts, a 1 s base delay and a 60 s cap, so a request that keeps failing waits at most 243 s before it gives up. bin/quak.ts loads the backup's session with them, so its refresh, ML data and downloads all use them; every other command keeps the default. What is retried and the backoff formula are unchanged. Model: opus-5-5
This commit was merged in pull request #174.
This commit is contained in:
@@ -43,6 +43,7 @@ import {
|
||||
isRetryable,
|
||||
isSafeToReplay,
|
||||
resolveRetryOptions,
|
||||
UNATTENDED_RETRY_OPTIONS,
|
||||
withRetry,
|
||||
} from "../../src/retry.js";
|
||||
import { ApiError, TruncatedStreamError } from "../../src/errors.js";
|
||||
@@ -639,3 +640,33 @@ describe("retry defaults", () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("unattended retry options", () => {
|
||||
it("allow ten attempts, a 1 s base delay and a 60 s cap", () => {
|
||||
// The numbers the README documents for `quak backup`.
|
||||
expect(UNATTENDED_RETRY_OPTIONS.attempts).toBe(10);
|
||||
expect(UNATTENDED_RETRY_OPTIONS.baseDelayMs).toBe(1_000);
|
||||
expect(UNATTENDED_RETRY_OPTIONS.maxDelayMs).toBe(60_000);
|
||||
});
|
||||
|
||||
it("give up on a request that keeps failing after at most 243 s of waiting", async () => {
|
||||
// `random: () => 1` makes every wait its ceiling, the worst case.
|
||||
const { sleep, delays } = recordingSleep();
|
||||
let calls = 0;
|
||||
await expect(
|
||||
withRetry(
|
||||
() => {
|
||||
calls++;
|
||||
return Promise.reject(new ApiError("HTTP 503", 503));
|
||||
},
|
||||
{ ...UNATTENDED_RETRY_OPTIONS, sleep, random: () => 1 },
|
||||
),
|
||||
).rejects.toThrow("HTTP 503");
|
||||
|
||||
expect(calls).toBe(10);
|
||||
expect(delays).toEqual([
|
||||
1_000, 2_000, 4_000, 8_000, 16_000, 32_000, 60_000, 60_000, 60_000,
|
||||
]);
|
||||
expect(delays.reduce((sum, ms) => sum + ms, 0)).toBe(243_000);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user