Skip to content
This repository has been archived by the owner on Nov 10, 2024. It is now read-only.

next_cursor overflow in get_friends #318

Closed
aaronrudkin opened this issue Mar 7, 2019 · 1 comment
Closed

next_cursor overflow in get_friends #318

aaronrudkin opened this issue Mar 7, 2019 · 1 comment
Labels

Comments

@aaronrudkin
Copy link
Contributor

aaronrudkin commented Mar 7, 2019

Problem

The next_cursor attribute (and thus, function) generated from get_friends occasionally overflows because something in the code is not properly using next_cursor_str.

Expected behavior

next_cursor returns a cursor to the next page of query results.

Reproduce the problem

library(tidyverse)
library(rtweet)

# create_token(...)

my_token = rtweet:::check_token(NULL)
next_token = -1
full_results = 1:20 %>% map(function(x) {
  print(paste("Working on page", x, "of verified users."))
  print(paste("Next cursor", next_token))
  current_rate_limit = rate_limit(my_token, "friends/ids")
  if(current_rate_limit$remaining == 0) {
    message("Waiting because out of rate limit")
    Sys.sleep(as.numeric(current_rate_limit$reset, "secs") + 2)
  }
  
  results = get_friends(users = "verified", 
                        n = 5000,
                        retryonratelimit = TRUE, 
                        page = next_token)

  next_token <<- next_cursor(results)
  results
}) %>% bind_rows()

Observe that after 16 pages, the next_cursor function returns an integer large enough to overflow into scientific notation. I believe this is because the code in get_friends_ which copies the next_cursor value into the table attribute uses next_cursor instead of next_cursor_str. I do notice that the next_cursor() S3 methods correctly check for next_cursor_str, but get_friends circumvents the next_cursor() function and directly sets the attribute from the [["next_cursor"]] item in the response.

rtweet version

0.6.8

@aaronrudkin
Copy link
Contributor Author

This PR should fix the narrow issue, although please note I did not check any other API methods for the same bug, and so it may be worth doing so.

@llrs llrs mentioned this issue Feb 15, 2021
@llrs llrs added the bug label Feb 16, 2021
@llrs llrs closed this as completed Feb 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants