cjbarrie/academictwitteR

Sleeping for -2 seconds. Error in utils::txtProgressBar(min = 0, max = sleep_period, initial = 0) : must have 'max' > 'min'

DrorWalt opened this issue · 9 comments

Both "get_user_following" and "get_all_tweets" sometimes return the following error message:

Rate limit reached. Rate limit will reset at 2021-08-05 19:50:00
Sleeping for -2 seconds.
Error in utils::txtProgressBar(min = 0, max = sleep_period, initial = 0) :
must have 'max' > 'min'
In addition: Warning message:
x-rate-limit-remaining=1. Resets at 2021-08-05 19:50:00

This doesn't happen all the time, but on long enough searches is often encountered. It happens on variety of searches, with differing parameters.

Session Info:

sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] forcats_0.5.1 stringr_1.4.0 dplyr_1.0.4 purrr_0.3.4 readr_1.4.0 tidyr_1.1.2 tibble_3.0.6 ggplot2_3.3.3 tidyverse_1.3.0 academictwitteR_0.2.1
[11] topicmodels_0.2-12 quanteda_2.1.2

loaded via a namespace (and not attached):
[1] jmvcore_1.2.23 colorspace_2.0-0 ggsignif_0.6.0 ellipsis_0.3.1 modeltools_0.2-23 rio_0.5.16 rprojroot_2.0.2 fs_1.5.0 rstudioapi_0.13 ggpubr_0.4.0 remotes_2.2.0
[12] lubridate_1.7.9.2 xml2_1.3.2 cachem_1.0.3 knitr_1.31 pkgload_1.1.0 jsonlite_1.7.2 rJava_0.9-13 broom_0.7.4 dbplyr_2.1.0 clipr_0.7.1 compiler_4.0.3
[23] httr_1.4.2 backports_1.2.1 assertthat_0.2.1 Matrix_1.2-18 fastmap_1.1.0 cli_2.3.0 cld2_1.2.1 htmltools_0.5.1.1 prettyunits_1.1.1 tools_4.0.3 igraph_1.2.6
[34] NLP_0.2-1 gtable_0.3.0 glue_1.4.2 tinytex_0.29 fastmatch_1.1-0 Rcpp_1.0.6 carData_3.0-4 slam_0.1-48 jquerylib_0.1.3 cellranger_1.1.0 vctrs_0.3.6
[45] lmtest_0.9-38 xfun_0.21 stopwords_2.2 ps_1.5.0 xlsxjars_0.6.1 openxlsx_4.2.3 testthat_3.0.2 rvest_0.3.6 lifecycle_1.0.0 devtools_2.3.2 rstatix_0.7.0
[56] xlsx_0.6.5 zoo_1.8-8 scales_1.1.1 hms_1.0.0 parallel_4.0.3 RColorBrewer_1.1-2 yaml_2.2.1 curl_4.3 memoise_2.0.0 sass_0.3.1 stringi_1.5.3
[67] highr_0.8 desc_1.2.0 pkgbuild_1.2.0 zip_2.1.1 rlang_0.4.10 pkgconfig_2.0.3 evaluate_0.14 lattice_0.20-41 processx_3.4.5 tidyselect_1.1.0 magrittr_2.0.1
[78] R6_2.5.0 generics_0.1.0 DBI_1.1.1 pillar_1.4.7 haven_2.3.1 foreign_0.8-80 withr_2.4.1 abind_1.4-5 modelr_0.1.8 crayon_1.4.1 car_3.0-10
[89] wordcloud_2.6 rmarkdown_2.7 usethis_2.0.1 grid_4.0.3 readxl_1.3.1 data.table_1.13.6 callr_3.5.1 digest_0.6.27 reprex_1.0.0 tm_0.7-8 RcppParallel_5.0.2
[100] stats4_4.0.3 munsell_0.5.0 bslib_0.2.4 jmv_1.2.23 sessioninfo_1.1.1

@DrorWalt English is not my mother-tongue, I want to make sure:

By "This doesn't happen all the time": Could you tell us whether 1) it doesn't happen all the time, but does happen all the time when it needs to sleep, or 2) it happens some of the time when it needs to sleep?

I need this information because 1) indicates a bug in our code and/or time zone settings and 2) indicates a random error from the Twitter side, which is not uncommon.

Update: I now tried it on 4 machines and it only happens on 1 of them.

English is not my mother-tongue as well so this miscommunication might be on me as well. It doesn't happen every time it sleeps, but if the query is long enough it will happen. It seemed to my like this is connected to the countdown bar for which the min bar value needs to be set at min of 0, and -2 screws it up. So I tried using verbose=FALSE and the issue persisted.

HOWEVER, initial issue was encountered on a windows remote server. I then tried it on my 3 personal devices and in none of them can this bug be replicated, so it seems to be machine specific. I am not sure why on windows server for some reason the sleep time will sometimes be calculated as negative. would be happy to provide more information, but this bug might be more too specific for you to invest major resources into, especially as I did not see anyone else posting about it yet.

@DrorWalt Thanks for providing further information and testing this in your multiple machines. I have a hypothesis but I also need more information from your machine with Windows Server. I don't have access to a Windows Server machine. Could you tell me the output of Sys.timezone() and Sys.time() on that server? Thank you very much!

Hi. This same error occurred to me as well. I am using a personal computer not a remote server. Tried several times different long queries and all resulted this error:

Error in utils::txtProgressBar(min = 0, max = sleep_period, initial = 0) : 
  must have 'max' > 'min'

Sys.timezone()
[1] "America/Sao_Paulo"

Sys.time()
[1] "2021-08-11 10:48:29 -03"

sessionInfo()

R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Mojave 10.14.6

@ombudsmanviktor I need more info. When you encounter this error again, could you please capture the entire output? The most important line is: Rate limit reached. Rate limit will reset at xxxxx

And then immediately run: Sys.time() and Sys.timezone()

I wanna know what went wrong. Thank you very much!

@DrorWalt @ombudsmanviktor At the moment without further information, I will introduce a prophylactic solution to this, i.e. the adaptive sleeping time (#167 ) will be disabled if sleep time is calculated as negative. It will be sleeping for 15 minutes, like the old versions.

You might want to try the new fix.

Hey @chainsawriot thank you so much for your fix. But seemingly when I added the param bind_tweets = FALSE to my query it did work well. Since then no more errors I think. Thanks a lot!

Same error here!

Error in utils::txtProgressBar(min = 0, max = sleep_period, initial = 0) :
must have 'max' > 'min'