diff --git a/CHANGELOG.md b/CHANGELOG.md index dca55500..0ce7b041 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ **Breaking changes** - ([#487](https://github.com/ramsayleung/rspotify/pull/487)) Change the type of `TrackLink.id` from `TrackId<'static>` to `Option>` +**Bugfixes** +- ([#494](https://github.com/ramsayleung/rspotify/pull/494)) Fix endless sequential pagination problem. + ## 0.13.3 (2024.08.24) **New features** - ([#490](https://github.com/ramsayleung/rspotify/pull/490)) Add impls for `Clone`, `Debug`, `PartialEq`, `Eq`, `Serialize` and `Hash` for `PlayContextId` and `PlayableId` diff --git a/src/clients/pagination/stream.rs b/src/clients/pagination/stream.rs index 05a8b329..bbf3aacf 100644 --- a/src/clients/pagination/stream.rs +++ b/src/clients/pagination/stream.rs @@ -28,6 +28,12 @@ where let request = req(&ctx, page_size, offset); let page = request.await?; offset += page.items.len() as u32; + // Occasionally, the Spotify will return an empty items with non-none next page + // So we have to check both conditions + // https://github.com/ramsayleung/rspotify/issues/492 + if page.items.is_empty() { + break; + } for item in page.items { yield Ok(item); }