MCPcopy Index your code
hub / github.com/simstudioai/sim / parseRetryAfter

Function parseRetryAfter

packages/utils/src/retry.ts:44–59  ·  view source on GitHub ↗
(header: string | null)

Source from the content-addressed store, hash-verified

42 * back to their own backoff.
43 */
44export function parseRetryAfter(header: string | null): number | null {
45 if (!header) return null
46 const trimmed = header.trim()
47 if (trimmed.length === 0) return null
48 const seconds = Number(trimmed)
49 if (Number.isFinite(seconds) && seconds >= 0) {
50 return Math.min(Math.floor(seconds * 1000), RETRY_AFTER_MAX_MS)
51 }
52 const dateMs = Date.parse(trimmed)
53 if (!Number.isNaN(dateMs)) {
54 const delta = dateMs - Date.now()
55 if (delta <= 0) return 0
56 return Math.min(delta, RETRY_AFTER_MAX_MS)
57 }
58 return null
59}

Callers 7

insertAllFunction · 0.90
fetchWithRetryFunction · 0.90
deliverFunction · 0.90
executeStatementFunction · 0.90
pollStatementFunction · 0.90
postWithRetriesFunction · 0.90

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected