Skip to content

Commit 0feede1

Browse files
committed
docs: add JSDoc for retryOn429 helpers (CodeRabbit docstring coverage)
1 parent 58c36c9 commit 0feede1

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎src/providers/key-failover.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ function cooldownKey(providerName: string, keyId: string): string {
3737
return `${providerName}\0${keyId}`;
3838
}
3939

40+
/**
41+
* Parse an upstream `Retry-After` header: numeric seconds (including `0`) or an HTTP-date.
42+
* Returns a bounded delay in ms (1..MAX_COOLDOWN_MS), or undefined when the value is
43+
* malformed. An HTTP-date already in the past yields an immediate (1 ms) retry.
44+
*/
4045
function parseRetryAfterMs(value: string | null | undefined, now = Date.now()): number | undefined {
4146
const text = value?.trim();
4247
if (!text) return undefined;

‎src/server/responses/core.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2585,6 +2585,11 @@ async function handleResponsesInner(
25852585
// main recovery loop above).
25862586
const rateLimitPolicy = rateLimitRetryPolicyFor(route.provider);
25872587
let rateLimitRetries = 0;
2588+
/**
2589+
* Build and fetch one terminal-guard continuation. `replay` marks a same-target 429
2590+
* replay so its send records the `rate-limit-429` recovery kind; the adapter rebuild is
2591+
* deterministic for the same parsed request (tests assert byte-identical replays).
2592+
*/
25882593
const fetchContinuation = async (replay = false): Promise<Response> => {
25892594
const continuationRequest = await activeAdapter.buildRequest(nextParsed, {
25902595
headers: selectedForwardHeaders,

0 commit comments

Comments
 (0)