Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

547 B
Raw Blame
// Retry-After (RFC 9110): delta-seconds or HTTP-date. Null means the server
// asked for no pacing, so the caller keeps its own backoff.
export function parseRetryAfterHeaderMs(
  value: string | null | undefined,
  maxMs: number,
  nowMs = Date.now()
): number | null {
  if (!value) {
    return null
  }
  const seconds = Number(value)
  const delayMs = Number.isFinite(seconds) ? seconds * 1_000 : Date.parse(value) - nowMs
  if (!Number.isFinite(delayMs) || delayMs <= 0) {
    return null
  }
  return Math.min(maxMs, Math.ceil(delayMs))
}