Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

fix: remove total class to fix pagination bug #169

Merged
merged 4 commits into from
Sep 27, 2023

Conversation

zemberdotnet
Copy link
Contributor

No description provided.

@zemberdotnet zemberdotnet requested a review from a team as a code owner September 27, 2023 15:38
@zemberdotnet zemberdotnet added bug Something isn't working release patch labels Sep 27, 2023
@zemberdotnet
Copy link
Contributor Author

image

The left column is total and the right column is seen resources. Notice how the total is the same and at times seen resources is higher than total. These are all for different ids so I think there is bug in the total.

I'm thinking the Total class is the source of the issue.

Comment on lines 381 to 387
if (!response.resources?.length && finished !== true) {
this.logger.info(
{ resourcesLength: response.resources?.length },
'response with zero resources, but finished is not true',
);
finished = true;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've put this here in case we run into the following edge case.

paginationParams.total = undefined;
total = 1000;
offset = 500;
response.resources.length = 0 || undefined;

// Seen will never grow larger, we'll get the same page forever.
seen += response.resources.length;
paginationParams.offset = seen;

I don't know if this will happen, but I want to know if it does and not create an infinite loop.

Comment on lines +381 to +384
if (
(!response.resources || response.resources.length === 0) &&
!finished
) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just noticed that response.resources.length is already accessed on line 364

Suggested change
if (
(!response.resources || response.resources.length === 0) &&
!finished
) {
if (response.resources.length === 0 && !finished) {

resourcePath,
);

this.total.setValue(baseUrl, paginationParams?.total);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this logic was confusing. I hope it's gone forever.

@zemberdotnet zemberdotnet merged commit cf2c5d9 into main Sep 27, 2023
@zemberdotnet zemberdotnet deleted the int-9704-fix-pagination-bug branch September 27, 2023 16:25
@j1-internal-automation
Copy link
Collaborator

🚀 PR was released in v3.10.1 🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working patch release released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants