Skip to content

Interface: PollContext\<T, A\>

Per-iteration context handed to PollProducer and the predicate on each step of a poll loop. Bundles the iteration metadata so the call signatures stay stable as poll grows additional fields.

signal is owned by poll: it tracks the external PollOptions.signal (when supplied) and also fires when the consumer breaks out of the loop, so producers can forward it to any in-flight work (fetch, SDK calls, etc.) and have a single cancellation source tear down both the request and the loop.

attributes is a mutable scratchpad shared across every iteration of a single poll run. The same object reference is passed each call so writes from one iteration are visible to the next - useful for stashing per-loop state (retry counters, start timestamps, anything you’d otherwise close over via a let). Generic A lets callers type the bag; defaults to Record<string, unknown>.

T

A = Record<string, unknown>

attempt: number

Zero-based iteration index (0 on the first call).


attributes: A

Per-run mutable scratchpad shared across iterations.


previous: T | undefined

Value yielded on the prior iteration; undefined on the first.


signal: AbortSignal

Cancellation handle. Always defined; forward to in-flight work.