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

Error: parse error: premature EOF #117

Open
lindbrook opened this issue Jul 25, 2023 · 6 comments
Open

Error: parse error: premature EOF #117

lindbrook opened this issue Jul 25, 2023 · 6 comments

Comments

@lindbrook
Copy link

Recently and with greater frequency, pkgsearch::cran_package_history() fails and returns:

Error: parse error: premature EOF

                (right here) ------^

This happens occasionally and often just re-running the function will be successful. To reproduce the error, you do the same: just re-run the function till it fails.

@gaborcsardi
Copy link
Contributor

I think this might happen because cloudflare returns a 404 or 403 or whatever they return when you make many requests, and pkgsearch does not handle that. pkgsearch:::http_get() or pkgsearch:::crandb_query() should handle status codes that are errors and throw an error for them.

@lindbrook
Copy link
Author

My typical use case is three or fewer packages with a loop like:

lapply(packages, pkgsearch::cran_package_history)

Had not seen it before. More frequent in the last few months (maybe 2023?). Especially this month.

@chainsawriot
Copy link

rang also uses pkgsearch::cran_package_history and it also appears to me that this parse error occurs only recently.

chainsawriot added a commit to gesistsa/rang that referenced this issue Jul 30, 2023
To make resolve more determinstic
chainsawriot added a commit to gesistsa/rang that referenced this issue Jul 30, 2023
* Fix #150 fix #149

* Retry when hit by r-hub/pkgsearch#117

To make resolve more determinstic
gaborcsardi added a commit that referenced this issue Jul 31, 2023
Hopefully it helps with #117.

I have no clue why CloudFlare returns 400 for the
repeated requests for the other endpoint,
and with their free tier I can't seem to be able
to dig deeper in the logs.

Nevertheless this entpoint seems to work better.

We can't easily turn off Cloudflare right now, we
would need to update the crandb server for that.
@gaborcsardi
Copy link
Contributor

Can you please try with the dev version of pkgsearch?

@lindbrook
Copy link
Author

Initial tests look good.

jennybc added a commit to hadley/r-pkgs that referenced this issue Aug 1, 2023
Relates to r-hub/pkgsearch#117 and intermittent "build and deploy" failures we're seeing due to an attempt to get a package's CRAN history.

Example log: https://github.com/hadley/r-pkgs/actions/runs/5711724736/job/15473842892

The failure I'm talking about:

```
Quitting from lines 59-67 [tbl-usethis-versions] (lifecycle.Rmd)
Error:
! parse error: premature EOF

                     (right here) ------^
Backtrace:
    ▆
 1. ├─knitr::kable(...)
 2. ├─dplyr::select(cran_package_history("usethis"), Version, Date = `Date/Publication`)
 3. └─pkgsearch::cran_package_history("usethis")
 4.   └─pkgsearch:::do_crandb_query(...)
 5.     └─pkgsearch:::crandb_query(ept)
 6.       └─jsonlite::fromJSON(cnt, ...)
 7.         └─jsonlite:::parse_and_simplify(...)
 8.           └─jsonlite:::parseJSON(txt, bigint_as_char)
 9.             └─jsonlite:::parse_string(txt, bigint_as_char)
```
@jennybc
Copy link

jennybc commented Aug 1, 2023

Also, so far so good in the GHA workflow that renders the R Packages book. But the experiment hasn't been running very long ...

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

No branches or pull requests

4 participants