@somnia-chain/markets-sdk / index / IndexerUnavailableError
Class: IndexerUnavailableError
Defined in: packages/sdk/src/errors.ts:674
The SDK stopped an indexer read locally.
Details
A breaker-open, breaker-trial, or queue-full refusal leaves no request
on the wire and returns at once instead of after a 30 s timeout.
A live-reset can stop a retry backoff after an earlier attempt was sent.
The breaker opens after IndexerLimits.breakerThreshold consecutive
endpoint failures (timeouts or HTTP 429/502/503/504) and stays open for
IndexerLimits.breakerCooldownMs.
When to use
Catch it to show "the indexer is not answering" at once rather than spinning a
skeleton. retryAfterMs says how much cooling period is left, so a poller can
sleep exactly that long.
Gotchas
A subclass of IndexerError, so existing instanceof IndexerError
handling is unaffected. A gate refusal (breaker-open, breaker-trial,
queue-full) means nothing reached the network: if a gate refuses a retry
after an earlier attempt was sent, the read fails with that attempt's
IndexerError instead. live-reset can end a retry's backoff, so an
earlier attempt may have been sent. Never retry it in a tight loop — that is the storm the
breaker exists to stop.
Branch on reason; the four cases want different things, and only
breaker-open carries a meaningful retryAfterMs:
reason | Means | Your move |
|---|---|---|
breaker-open | Consecutive endpoint failures opened the breaker | Sleep retryAfterMs, then retry |
breaker-trial | The cooling period ended and another read is the trial | Retry shortly; the trial decides |
queue-full | This client already has maxQueued reads waiting for a slot | Back off on your own schedule (nextBackoffDelayMs) or send less |
live-reset | stopLive() reset the live-read lifecycle while this read queued or backed off | Retry on the SAME client; it stays usable |
Example (Sleeping for exactly the cooling period)
import { IndexerUnavailableError } from "@somnia-chain/markets-sdk";
try {
await exchange.client.listBinaryMarkets();
} catch (e) {
if (!(e instanceof IndexerUnavailableError)) throw e;
// Only `breaker-open` carries a cooling period; the rest retry sooner.
await new Promise((r) => setTimeout(r, e.retryAfterMs || 1_000));
}
Extends
Constructors
Constructor
new IndexerUnavailableError(
operation,reason,detail,retryAfterMs,consecutiveFailures):IndexerUnavailableError
Defined in: packages/sdk/src/errors.ts:689
Creates a locally-refused indexer error.
Details
operation: GraphQL operation name that was refused.reason: Which gate refused, and so what the caller should do next.detail: Why the SDK refused, in prose.retryAfterMs: Cooling period remaining. Meaningful only forbreaker-open;0for every other reason, where the wait is the caller's own backoff rather than a period the SDK knows.consecutiveFailures: Endpoint failures in a row recorded so far: timeouts and overload responses (HTTP 429, 502, 503, 504).
Parameters
operation
string
reason
detail
string
retryAfterMs
number
consecutiveFailures
number
Returns
IndexerUnavailableError
Overrides
Properties
chainId?
readonlyoptionalchainId?:number
Defined in: packages/sdk/src/errors.ts:253
The chain whose read failed. Set only on an exchange with two or more
chains, in two cases. The account reads of SomniaMarkets
(fetchBalance, fetchOpenOrders, fetchOrders, getOrdersPage,
getOrderHistoryPage, fetchMyTrades, fetchPositions,
fetchOpenStopOrders, watchUser) set it when the read spans more than
one chain, or when the read has no market and no chain filter, also if it
then touches only one chain. fetchDataStatus sets it on the error it
throws when every chain fails. Absent on every other indexer error.
Inherited from
operation
readonlyoperation:string
Defined in: packages/sdk/src/errors.ts:265
Inherited from
reason
readonlyreason:IndexerRefusalReason
Defined in: packages/sdk/src/errors.ts:691
retryAfterMs
readonlyretryAfterMs:number
Defined in: packages/sdk/src/errors.ts:693
consecutiveFailures
readonlyconsecutiveFailures:number
Defined in: packages/sdk/src/errors.ts:694