Open Skylertodd opened 5 months ago
That's a really interesting edge case, thank you very much for reporting here! Is this something you'd be interested in attempting to fix? I'd be more than happy to review a PR. Just let me know, thanks again @Skylertodd for such a thorough bug report.
When I was initially investigating, I thought it would be easy to dynamically set page size based on remaining records... however it appears that the feedIterator is immutable and it would require a bit of a refactor to separate out the continuation token, query, and paging information. If I find some time, I might toss something together, for now I decided to work around it by lowering the count of items being returned.
Apparent Behavior: Continuation token skipping records when fetching page 2.
When setting a larger page size and dealing with large documents, there is an edge case where Cosmos DB returns fewer items than the desired page size due to size limitations (believed to be 4MB). This results in an issue where the iterator fetches another page of items, causing the total fetched items to exceed the desired amount. The continuation token reflects this higher number, but when iterating through the results, extra records are discarded to match the exact requested count. Consequently, when fetching subsequent pages, records that were discarded are skipped.
Steps to Reproduce / Example Scenario:
Expected Behavior / Recommendation:
Reference Code: DefaultRepository.cs#L50