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

Pagination goes into infinite loop when querying empty lists #71

Open
Skogsfrae opened this issue Feb 19, 2019 · 6 comments
Open

Pagination goes into infinite loop when querying empty lists #71

Skogsfrae opened this issue Feb 19, 2019 · 6 comments
Assignees
Labels
Milestone

Comments

@Skogsfrae
Copy link

When requesting a paginated resource with no values the paginator goes into an infinite loop of requests to the spotify api.

To reproduce the bug I made this query on a user with no public playlists

{
   user(id: "someid"){
    playlists{
      name
    }
  }
}

The api returns an empty list with total=0, but the !!iterator.total condition inside the shouldStopIterate function causes and infinite loop of requests.

Skogsfrae pushed a commit to Skogsfrae/spotify-graphql that referenced this issue Feb 19, 2019
Skogsfrae added a commit to Skogsfrae/spotify-graphql that referenced this issue Feb 19, 2019
@Skogsfrae
Copy link
Author

I published the first commit with a wrong email, then i amended it with the correct email, sorry 😅

@charlypoly
Copy link
Owner

Hi @Skogsfrae,

Thanks for pointing this! 💯🙇

Please free to make a PR on this repo so I can review & publish it to npm 🚢

@pavittar95
Copy link

pavittar95 commented Jul 3, 2020

I'm having the same problem can give an example to stop it from looping again and again. This is the result.

{
  "href" : "https://api.spotify.com/v1/users/31qkotz7ttscfyanfn4iktz4zcgi/playlists?offset=5950&limit=50",
  "items" : [ ],
  "limit" : 50,
  "next" : null,
  "offset" : 5950,
  "previous" : "https://api.spotify.com/v1/users/31qkotz7ttscfyanfn4iktz4zcgi/playlists?offset=5900&limit=50",
  "total" : 0
}

The next API call should be stopped if the next null and items are empty

@pavittar95
Copy link

@wittydeveloper are you still maintaining this package?

@Skogsfrae
Copy link
Author

@pavittar95 you can use my fork containing the fix if you want.
It's linked to this issue

@charlypoly
Copy link
Owner

Will take a look in spotify-graphql@4.0.0, cf: #79

@charlypoly charlypoly added this to the 4.0.0 milestone Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants