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:
- Fast Phase: Initial rapid polling (default: 10 attempts @ 100ms intervals)
- Ramp Phase: Exponential backoff growth (default: up to 20s elapsed)
- 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.
Parameters
Section titled “Parameters”PollingConfig = {}
Configuration options
Returns
Section titled “Returns”PollStrategy
- Async strategy function compatible with agent pollingOptions.strategy
Example
Section titled “Example”// Basic usageconst strategy = createPollingStrategy();
// Custom configuration for long-running operationsconst strategy = createPollingStrategy({ context: "blockchain-sync", fastAttempts: 5, fastDelayMs: 200, rampUntilMs: 30_000, plateauDelayMs: 10_000, jitterRatio: 0.3});
// With abort signalconst controller = new AbortController();const strategy = createPollingStrategy({ context: "transaction-signing", abortSignal: controller.signal});// Later: controller.abort();Throws
Section titled “Throws”When abortSignal is triggered during polling
Throws
Section titled “Throws”With TimeoutWaitingForResponseErrorCode when a
request has been polled for timeoutMs