Skip to content
Docs

Requests and responses

Timeouts and retries

Set client deadlines; retry only when retryable is true or the transport failed.

Overview

Gray3 does not publish a single global SLA timeout. Your HTTP client should set explicit deadlines and retry only when error.retryable is true (or the transport failed before a JSON body).

Suggested client timeouts

  • Single-chain reads (portfolio, balance, prices, gas) — 15–30s
  • Multi portfolio / large price batches — 30–60s (sequential or batched fan-out)
  • Transaction prepare / simulate / broadcast — 30–60s

Request size limit

Request bodies are limited to 256 KiB. Larger bodies are rejected with HTTP 413 and the code invalid_argument before they are processed. Split large batches, such as price lookups, into several requests.

Retry policy

  • Safe: idempotent GETs when retryable: true or on network blips before a response
  • Careful: POSTs that prepare or broadcast—avoid double-broadcast of the same signed payload; use your own idempotency keys in app logic
  • Honor Retry-After on 429 when present — see Backoff strategy
javascript
async function withBackoff(fn, { maxAttempts = 5 } = {}) {
  let delay = 250;
  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
    const res = await fn();
    if (res.status !== 429 && res.status < 500) return res;
    const body = await res.clone().json().catch(() => null);
    if (body?.error && body.error.retryable === false) return res;
    const retryAfter = Number(res.headers.get("retry-after"));
    const waitMs = Number.isFinite(retryAfter)
      ? retryAfter * 1000
      : delay + Math.random() * delay;
    await new Promise((r) => setTimeout(r, waitMs));
    delay = Math.min(delay * 2, 8000);
  }
  return fn();
}

SDK note

Network / non-JSON failures from cloud typically surface as provider_unavailable (retryable: true) in the TypeScript SDK.

Related: Retryable vs not, Idempotency and retries.