Skip to content

Page and retry policies

new Page(items: T[], cursor: string | null)
Parameter Type Description
items T[]
cursor string | null
Property Type Description
cursor string | null
items T[]
hasMore boolean True when another page exists.
length number
[iterator](): Iterator<T>

Returns Iterator<T>.

at(index: number): T | undefined

The item at index; negative counts from the end.

Parameter Type Description
index number

Returns T \| undefined.

How many times to try a call, and how long to wait between tries. The default is 3 attempts, 500 ms initial backoff doubling to a 30 s cap, with jitter. new RetryPolicy({ maxAttempts: 1 }) (or NO_RETRY) turns retries off.

new RetryPolicy(opts?: RetryPolicyOptions)
Parameter Type Description
opts (optional) RetryPolicyOptions
opts.initialBackoffMs (optional) number Milliseconds before the first retry. Default 500.
opts.jitter (optional) boolean Randomise each wait between 50% and 100% of its value. Default true.
opts.maxAttempts (optional) number Total attempts, including the first. Default 3.
opts.maxBackoffMs (optional) number Cap on any one wait, in milliseconds. Default 30000.
opts.retryableExceptions (optional) readonly ExceptionClass[] Exception classes eligible for a retry.
Property Type Description
initialBackoffMs number
jitter boolean
maxAttempts number
maxBackoffMs number
retryableExceptions readonly ExceptionClass[]
computeBackoffMs(attempt: number, exc: STXException): number

Milliseconds to wait after attempt attempt (1-based) failed.

Parameter Type Description
attempt number
exc STXException

Returns number.

shouldRetry(exc: STXException, attempt: number, idempotent: boolean): boolean

Whether to try again after exc ended attempt number attempt.

Parameter Type Description
exc STXException
attempt number
idempotent boolean

Returns boolean.

Backoff between reconnect attempts.

new ReconnectPolicy(opts?: ReconnectPolicyOptions)
Parameter Type Description
opts (optional) ReconnectPolicyOptions
opts.initialBackoffMs (optional) number
opts.jitter (optional) boolean
opts.maxAttempts (optional) number | null null (the default) never gives up.
opts.maxBackoffMs (optional) number
Property Type Description
initialBackoffMs number
jitter boolean
maxAttempts number | null
maxBackoffMs number
delayMs(attempt: number): number
Parameter Type Description
attempt number

Returns number.

v1.5.9Changelogllms.txtllms-full.txt