@orangecheck/me-client / withRateLimitRetry
Function: withRateLimitRetry()
function withRateLimitRetry<T>(fn: () => Promise<T>, opts?: WithRateLimitRetryOptions): Promise<T>;
Defined in: me-client/src/transport.ts:170
Wrap a transport call with automatic 429 retry, honoring Retry-After.
import { oc, withRateLimitRetry } from '@orangecheck/me-client';
const res = await withRateLimitRetry(() => oc.event.fireBatch({ project_key, events }) );
Retries ONLY on 429 (rate-limit) responses. All other errors throw
immediately so the caller can handle them. Sleeps for Retry-After
seconds when present (capped at maxRetryAfterSeconds); otherwise
uses exponential backoff from baseBackoffMs.
Per OCHK-V3-PLAN §12.6 — backpressure protocol. The server emits 429 + Retry-After when a project crosses its 1000 events/sec sustained cap; this helper honors it without integrators having to write the sleep loop.
Idempotency note: integrators using event.fireBatch should pass an
idempotency_key per event so a retry doesn't double-record. The
server collapses retried events to a duplicate status with the
prior payload.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
fn | () => Promise<T> |
opts | WithRateLimitRetryOptions |
Returns
Promise<T>