Skip to main content
Version: 1.7.0

Class: CCIPRateLimitExceededError

Defined in: errors/specialized.ts:828

Thrown when TokenPool's rate limit is not enough for the requested amount. Transient: rate limit may refill after some time, or user can reduce amount and retry immediately. Not transient: amount exceeds total capacity of the pool, so it will never be processable until pool configs change.

Example

TypeScript
let fee
do {
try {
fee = await chain.getFee({
router,
destChainSelector,
message: { receiver, tokenAmounts: [{ token, amount }] },
})
} catch (error) {
if (!(error instanceof CCIPRateLimitExceededError) || !error.isTransient) {
throw error
}
console.log(`Token ${error.context.token} exceeds rate limit, retrying after ${error.retryAfterMs}ms`)
await sleep(error.retryAfterMs)
}
} while (fee === undefined)

Extends

Constructors

Constructor

new CCIPRateLimitExceededError(direction: "INBOUND" | "OUTBOUND", rateLimiterState: { capacity: bigint; rate: bigint; tokens: bigint; }, tokenInfo: { amount: bigint; destChainSelector: bigint; registry?: string; sourceChainSelector: bigint; token: string; tokenPool: string; }, options?: CCIPErrorOptions): CCIPRateLimitExceededError

Defined in: errors/specialized.ts:831

Creates a rate limit exceeded error.

Parameters

ParameterTypeDescription
direction"INBOUND" | "OUTBOUND"-
rateLimiterState{ capacity: bigint; rate: bigint; tokens: bigint; }-
rateLimiterState.capacitybigintMaximum capacity of the rate limiter bucket.
rateLimiterState.ratebigintRate at which tokens are replenished (tokens per second).
rateLimiterState.tokens?bigintCurrent token balance in the rate limiter bucket.
tokenInfo?{ amount: bigint; destChainSelector: bigint; registry?: string; sourceChainSelector: bigint; token: string; tokenPool: string; }-
tokenInfo.amount?bigint-
tokenInfo.destChainSelector?bigint-
tokenInfo.registry?string-
tokenInfo.sourceChainSelector?bigint-
tokenInfo.token?string-
tokenInfo.tokenPool?string-
options?CCIPErrorOptions-

Returns

CCIPRateLimitExceededError

Overrides

CCIPError.constructor

Properties

_isCCIPError

readonly _isCCIPError: true

Defined in: errors/CCIPError.ts:30

Brand for cross-module identification (dual package hazard).

Inherited from

CCIPError._isCCIPError


code

readonly code: CCIPErrorCode

Defined in: errors/CCIPError.ts:32

Machine-readable error code.

Inherited from

CCIPError.code


context

readonly context: Record<string, unknown>

Defined in: errors/CCIPError.ts:34

Structured context (IDs, addresses).

Inherited from

CCIPError.context


isTransient

readonly isTransient: boolean

Defined in: errors/CCIPError.ts:36

True if retry may succeed.

Inherited from

CCIPError.isTransient


name

readonly name: "CCIPRateLimitExceededError" = 'CCIPRateLimitExceededError'

Defined in: errors/specialized.ts:829

Overrides

CCIPError.name


recovery?

readonly optional recovery?: string

Defined in: errors/CCIPError.ts:40

Recovery suggestion.

Inherited from

CCIPError.recovery


retryAfterMs?

readonly optional retryAfterMs?: number

Defined in: errors/CCIPError.ts:38

Retry delay in ms.

Inherited from

CCIPError.retryAfterMs

Methods

toJSON()

toJSON(): Record<string, unknown>

Defined in: errors/CCIPError.ts:105

Serializes the error for logging.

Use this instead of JSON.stringify(error) directly, as Error properties are non-enumerable and would be lost.

Returns

Record<string, unknown>

An object containing all error properties

Inherited from

CCIPError.toJSON


from()

static from(error: unknown, code?: CCIPErrorCode): CCIPError

Defined in: errors/CCIPError.ts:89

Wraps an unknown caught value in a CCIPError.

Useful for normalizing errors in catch blocks.

Parameters

ParameterTypeDescription
errorunknownThe error to wrap
code?CCIPErrorCodeOptional error code (defaults to 'UNKNOWN')

Returns

CCIPError

A CCIPError wrapping the original error

Inherited from

CCIPError.from


isCCIPError()

static isCCIPError(error: unknown): error is CCIPError

Defined in: errors/CCIPError.ts:73

Type guard for CCIPError.

Prefer this over instanceof to handle the dual package hazard when multiple versions of the SDK may be present.

Parameters

ParameterTypeDescription
errorunknownThe error to check

Returns

error is CCIPError

True if the error is a CCIPError instance

Inherited from

CCIPError.isCCIPError