Skip to content
IC Reactor

createPollingStrategy

createPollingStrategy(cfg?): PollStrategy

Defined in: core/src/utils/polling.ts:250

Creates an polling strategy for Internet Computer agent update calls.

The strategy implements three phases:

  1. Fast Phase: Initial rapid polling (default: 10 attempts @ 100ms intervals)
  2. Ramp Phase: Exponential backoff growth (default: up to 20s elapsed)
  3. Plateau Phase: Steady-state polling (default: 5s intervals)

The strategy continues polling while request status is RECEIVED/PROCESSING, and terminates on REPLIED/REJECTED/DONE status, when aborted, or once the request has been polled for timeoutMs.

One strategy can be shared, for example by every update call of a reactor through its pollingOptions. Each request, told apart by its request ID, gets its own attempt count, clock and timeout, so a call that starts later still begins in the fast phase.

PollingConfig = {}

Configuration options

PollStrategy

  • Async strategy function compatible with agent pollingOptions.strategy
// Basic usage
const strategy = createPollingStrategy();
// Custom configuration for long-running operations
const strategy = createPollingStrategy({
context: "blockchain-sync",
fastAttempts: 5,
fastDelayMs: 200,
rampUntilMs: 30_000,
plateauDelayMs: 10_000,
jitterRatio: 0.3
});
// With abort signal
const controller = new AbortController();
const strategy = createPollingStrategy({
context: "transaction-signing",
abortSignal: controller.signal
});
// Later: controller.abort();

When abortSignal is triggered during polling

With TimeoutWaitingForResponseErrorCode when a request has been polled for timeoutMs