Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed infinite loop on list pagination when the result had more than 1 item #477

Merged
merged 5 commits into from
Jan 24, 2024
Merged

Fixed infinite loop on list pagination when the result had more than 1 item #477

merged 5 commits into from
Jan 24, 2024

Conversation

skytz
Copy link
Contributor

@skytz skytz commented Jan 14, 2024

Summary

Checklist

  • [ X ] ran cargo make fmt
  • [ X ] using conventional commits to hightlight user-facing fixes and features

fix: Fixed infinite loop on list pagination when the result had more than 1 item

I also added tests with 2 elements, so this never happens again.

What was happening:
The get_data implementations of PaginableList was cloning the data every single time.
When the data was "popped" in the unfold_stream function, it was popping from the cloned vector.
Specifically the if paginator.page.data.len() > 1 { ... as with anything less than than 2 elements, the condition was false and it either ended the stream or requested the next page.

@arlyon
Copy link
Owner

arlyon commented Jan 24, 2024

Hey! Thanks for taking the time to sort this silly bug. CI is running and I will get a release out when it is ready.

@arlyon
Copy link
Owner

arlyon commented Jan 24, 2024

Hope you don't mind I took the time to fix the trivial sync issue and add a test for it. Thanks for putting this together!

@arlyon arlyon merged commit 306b94c into arlyon:master Jan 24, 2024
16 checks passed
@skytz
Copy link
Contributor Author

skytz commented Feb 5, 2024

Thanks for merging it!

Would you mind publishing a new version with this fixed on crates.io?
The last version there is the one right before merging this one, and it still has the issue.

@skytz skytz deleted the paginator-infinity-loop-fix branch April 25, 2024 10:34
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.

2 participants