Skip to content
Français

watchRun

import { watchRun } from "@elie-laloum/outpost/observation";

Replay published observation segments strictly after from, then poll while the snapshot is running. Stop after draining a settled or abandoned snapshot. Persistent cursors continue across settled workflow resumes; heartbeat writes do not advance them. Signal cancellation affects only this reader. Missing segments, invalid records and cursors ahead of the snapshot throw.

Complete example and detailed rules.

  • optionsRequired
    WatchRunOptions
    Run lookup, exclusive cursor, polling interval and optional reader cancellation.
  • options.fromOptional
    number | undefined
    Exclusive persistent cursor, default 0; negative, fractional or ahead-of-snapshot cursors fail.
  • options.pollMsOptional
    number | undefined
    Positive polling period in milliseconds while running, default 1000.
  • options.transporterRequired
    Transport
    Transport targeting the same location as the execution receiver.
  • options.idRequired
    string
    Application-selected run ID to read without taking execution ownership.
  • options.signalOptional
    AbortSignal | undefined
    Cancel transport reads and watch polling only; never cancels the observed execution.
  • options.maxBytesOptional
    number | undefined
    Per-object read limit in bytes, default 8388608; oversized snapshots or event segments fail.

AsyncIterable<RunEvent>

export declare function watchRun(
  options: WatchRunOptions,
): AsyncIterable<RunEvent>;