Skip to content

fix: stop cyclic pagination with typed progress errors - #59

Open
thedogwiththedataonit wants to merge 4 commits into
mainfrom
codex/pagination-cycle-guard
Open

thedogwiththedataonit wants to merge 4 commits into
mainfrom
codex/pagination-cycle-guard

Conversation

@thedogwiththedataonit

@thedogwiththedataonit thedogwiththedataonit commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

When a list endpoint repeats a cursor, listAll() can fetch the same pages indefinitely. Stop before refetching a known cursor and throw an exported BrewPaginationError with PAGINATION_CURSOR_CYCLE, the repeated cursor, fetched page count, and already-yielded item count.

The iterator follows empty pages with advancing cursors and accepts terminal or missing pagination. An abort between pages still ends iteration quietly, including when it coincides with a repeated cursor; in-flight request cancellation and retry behavior retain their existing contracts. Error documentation explains that yielded partial results are incomplete and the repeated cursor is diagnostic information. The example uses the actual contacts searchAll() API.

Validation at f82d066fc14ccb6918a28d5cb1c8623c7da4ea0d: Bun 1.3.10 typecheck, ESLint, read-only Prettier check, all 649 tests in 107 files, and ESM/CJS/declaration builds passed. Both built module formats expose the error correctly. Regression coverage includes identical and multi-page cycles, advancing empty pages, terminal pagination, and cancellation while consuming a page with a cyclic next cursor. CI is green on this head.

Latest main is merged, including the canonical Figma import link overrides. Regenerate the OpenAPI mirror and types from merged application Stripe PR #2035: six contact-response consent-source unions add integration, documenting provenance without asserting an opt-in. Request consent-source enums retain their existing contract. The four coordinated application, docs, SDK, and CLI OpenAPI mirrors match SHA-256 4d68ab8d4877bca19f206e2153fa2cde65b3240767f033d051fb1b6667aff75f; application Figma PR #2029 is merged. This PR exports an additive SDK API and does not change the package version. Release the SDK before a future CLI dependency update adopts its new API; the companion CLI fix uses its own pagination error and keeps the published SDK dependency.

Companion CLI PR #48; coordinated docs contract-sync PR #200; application review PR #2027.

Comment thread src/core/pagination.ts
Comment thread docs/errors.md Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant