Skip to content

createPollingStrategy

createPollingStrategy(cfg?): PollStrategy

Defined in: utils/polling.ts:191

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 only terminates on REPLIED/REJECTED/DONE status or when aborted.

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