@somnia-chain/markets-sdk


@somnia-chain/markets-sdk / index / IndexerWaitTimeoutError

Class: IndexerWaitTimeoutError

Defined in: packages/sdk/src/errors.ts:344

The indexer did not reach a requested block before the wait's deadline.

When to use

Catch it to decide what to do about LAG. The read itself worked: the indexer answered every poll and is simply behind, so the choices are to wait longer, to show the caller that the data is not there yet, or to read the same fact from chain instead. latestProcessedBlock says how far it had got, so the decision can be made on the size of the gap rather than on the timeout alone.

Gotchas

This is NOT an IndexerError: the indexer was reachable throughout. A request that failed to complete during the wait surfaces as IndexerError, and a chain the indexer serves no metadata row for does too — neither is cured by waiting.

Example (Falling back to chain when the index is behind)

ts
import { IndexerWaitTimeoutError } from "@somnia-chain/markets-sdk";

try {
  await exchange.client.waitForIndexedBlock(exchange.client.config.chain.id, receipt.blockNumber);
} catch (e) {
  if (!(e instanceof IndexerWaitTimeoutError)) throw e;
  console.warn(`indexer is ${e.targetBlock - (e.latestProcessedBlock ?? 0)} blocks behind`);
}

Extends

Constructors

Constructor

new IndexerWaitTimeoutError(targetBlock, latestProcessedBlock, timeoutMs, waitedMs, polls): IndexerWaitTimeoutError

Defined in: packages/sdk/src/errors.ts:357

Creates a wait-timeout error carrying the observation that ran out of time.

Details

  • targetBlock: Block the caller waited for.
  • latestProcessedBlock: Last height the indexer reported, or null when it reported a chain row that had processed nothing.
  • timeoutMs: Deadline the wait was given.
  • waitedMs: Time actually spent waiting.
  • polls: Number of metadata reads performed.

Parameters

targetBlock

number

latestProcessedBlock

number | null

timeoutMs

number

waitedMs

number

polls

number

Returns

IndexerWaitTimeoutError

Overrides

SomniaMarketsError.constructor

Properties

targetBlock

readonly targetBlock: number

Defined in: packages/sdk/src/errors.ts:358


latestProcessedBlock

readonly latestProcessedBlock: number | null

Defined in: packages/sdk/src/errors.ts:359


timeoutMs

readonly timeoutMs: number

Defined in: packages/sdk/src/errors.ts:360


waitedMs

readonly waitedMs: number

Defined in: packages/sdk/src/errors.ts:361


polls

readonly polls: number

Defined in: packages/sdk/src/errors.ts:362