Skip to content

RESTHooks

Defined in: packages/rest/src/index.ts:205

Lightweight callback hooks for REST request lifecycle events.

All callbacks are optional. They are dispatched in isolation from the request path (deferred to a microtask, and any thrown error is swallowed), so a hook cannot break or reject a request. Even so, hooks must be fast and non-blocking: heavy synchronous work in a hook still steals event-loop time from in-flight requests. Offload anything expensive to your own queue.

optional onRateLimit(ctx): void

Defined in: packages/rest/src/index.ts:211

Called when a rate limit is encountered and the client is about to wait.

RESTRateLimitContext

void


optional onRequest(ctx): void

Defined in: packages/rest/src/index.ts:207

Called just before every HTTP attempt.

RESTRequestContext

void


optional onResponse(ctx): void

Defined in: packages/rest/src/index.ts:209

Called after a successful or failed response is received.

RESTResponseContext

void


optional onRetry(ctx): void

Defined in: packages/rest/src/index.ts:213

Called when a failed request is about to be retried.

RESTRetryContext

void