fix(pagination): stop ScanAndCollectN before fetching an unneeded page

Fixes #2309 (closed)

ScanAndCollectN checked its limit only when the next item arrived. After collecting n items it still requested the next page, which caused two problems:

  • One extra API call whenever n items had been collected and another page existed.
  • If that extra request failed, the n items already collected were thrown away and the error was returned.

Merge request reports

Loading
Loading