Skip to content

Pull-based streams and resource lifetimes

Adapter design. This page specifies the unpublished adapter. Run a request with Octokit and Effect.

Accept an iterator factory so two runs of a Stream start independently. Allocate iterator, per-run signal and finalizer at stream acquisition. Pull one page at a time. Preserve page order and upstream data. Flatten items lazily; stopping after one record can consume a fetched page but must not start another. An empty page can still have a successor. Whole-collection calls remain explicit.

On early stop, failure or scope close, abort the active fetch started by that stream first and call the iterator’s optional return when available. The REST iterator at the recorded baseline lacks return. Wrapping an existing promise in an async iterable is insufficient. Verify cancellation at fetch on the second page and separate simultaneous stream runs. An App iterator or a custom async iterable can hide its transport. Document whether stopping it can abort an active fetch.

REST pages carry normalized response metadata. GraphQL pages yield query-shaped data. Installation and repository streams yield the corresponding client with each record. Push-based webhook events require a separate bounded subscription with explicit overflow/ack semantics. Global buffering, speculative page prefetch, shared cursors, silent drop and implicit accumulation do not belong in this module.

Check. A consumer sees page one before page two fails. Retrying a whole stream can repeat already-emitted values; leave replay/deduplication to the consumer. Check cleanup on take(0), take(1), pull rejection, consumer failure and concurrent cancellation. Effect streams