Skip to main content
Use the service-specific rate-limit reference to find your endpoint’s quota and response headers. This guide implements retries for GET requests only. It does not assume that writes can be replayed or that pausing a queue retries a failed item.

Before you start

Use Node.js 20.20.0+. The helper uses built-in fetch, AbortSignal.timeout, and timers; no StateSet SDK or hosted credentials are needed to run the regression tests in this repository. For a live read, select a provisioned host and an appropriately scoped key from the API directory.

Save the retry helper

Save this as rate-limit.mjs. The function makes at most maxAttempts requests, bounds each request’s timeout, and refuses a server delay larger than maxWaitMs instead of retrying early. The limits are application policy, not StateSet plan limits.
A network error or request timeout propagates immediately. This helper deliberately has no policy for retrying 5xx, parsing service error bodies, or retrying mutations. Add those only with operation-specific tests and a documented replay policy.

Call one read endpoint

Save this as read-agents.mjs beside the helper:
Success: the read returns HTTP 200 and prints a count. A count of zero is valid for an empty workspace. An exhausted retry budget throws; it does not return a fabricated empty list.

Verify failure behavior

From this documentation repository, run:
The retry tests extract the helper directly from this page. They inject responses and a fake clock/sleep so they can assert exact request counts and delays without network access or real waiting. They cover throttling followed by success, exhaustion, non-retryable errors, dates, malformed headers, oversized delays, and invalid configuration.

Operate under sustained load

One helper call controls only its own attempts. Coordinate concurrency across workers sharing a tenant or API key, bound queue length, and record throttle counts and wait times. When a read is deferred, retain its job identity so a worker can resume it intentionally. Continue with the integration test plan before enabling retries in production.
Last modified on September 21, 2026