fix: keep pagination iterators advancing past fully filtered pages - #1044
Open
vdusek wants to merge 4 commits into
Open
fix: keep pagination iterators advancing past fully filtered pages#1044vdusek wants to merge 4 commits into
vdusek wants to merge 4 commits into
Conversation
Contributor
|
See more at https://github.com/apify/apify-client-js/actions/runs/34473247015#summary-102857850927 |
vdusek
marked this pull request as ready for review
September 9, 2026 08:52
barjin
reviewed
Sep 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
Description
The offset-based iterator stopped as soon as a page came back with no items, and advanced the offset by the number of items returned. Dataset filters (
clean,skipEmpty,skipHidden) apply afteroffsetandlimit, so a page can scan up tolimitrows while returning fewer, or none at all.listItems()used as an async iterable therefore ended early on a fully filtered page, and re-yielded rows an earlier page had already returned.The iterator now paginates by the scanned count the API reports in
x-apify-pagination-count, and by that number alone.items.lengthcannot stand in for it in either direction: filters leave it below the rows scanned andunwindcan leave it above, so mixing the two would skip rows.PaginatedList.countstaysitems.length, since it is public and intentionally set that way; the scanned number travels with the page as a non-enumerable symbol property outside the public shape. Collection endpoints send no such header and fall back toitems.length, so nothing about them changes.The cursor iterators (
listKeys(),listRequests(),paginateRequests()) are unchanged. The API never returns an empty page together with a cursor: the request queue listing hands outnextCursoronly when it filled the whole page, and the key-value store listing derivesnextExclusiveStartKeyfrom the last key it returned.Test plan
Regression tests for the fully filtered page, the duplicated offset, and
unwindreturning more items than rows scanned.✍️ Drafted by Claude Code