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
Expose curl options in use_course() and friends? #988
Comments
@gaborcsardi alerted me to some relevant subtleties. It's too crude to talk about timeout, because it applies to the whole download. What we really want to know is whether we are continuing to make progress (don't timeout) vs. being dead in the water (do timeout). Some relevant code from async: https://github.com/r-lib/async/blob/6494de0ba468cf25e5625fc5fde2236f90d5016f/R/http.R#L187-L190 Inlining:
More about such config:
If we bump up against the above, (lib)curl will error with something like:
|
Yeah, the above code has some boilerplate specific to the async package, the gist is to set the
|
I'd be in favour of increasing the timeout, but not exposing it as an option. |
More about the relevant curl options: From https://curl.haxx.se/libcurl/c/CURLOPT_TIMEOUT.html
From https://curl.haxx.se/libcurl/c/CURLOPT_CONNECTTIMEOUT.html
From https://curl.haxx.se/libcurl/c/CURLOPT_LOW_SPEED_TIME.html
From https://curl.haxx.se/libcurl/c/CURLOPT_LOW_SPEED_LIMIT.html
Defaults that we inherit from the curl package: packageVersion("curl")
#> [1] '4.3'
interesting_options <- c(
curl::curl_options("timeout"),
curl::curl_options("speed")
)
keepers <- c("timeout", "connecttimeout", "low_speed_limit", "low_speed_time")
interesting_options[keepers]
#> timeout connecttimeout low_speed_limit low_speed_time
#> 13 78 19 20 Created on 2020-03-26 by the reprex package (v0.3.0.9001) |
I believe these are just the code numbers of the options (as for an enum). Not the actual default values. curl only sets |
OK maybe here is where one default is set: https://github.com/jeroen/curl/blob/d28579517f7af7646ab21300c65ee4e121398ab1/src/handle.c#L163 → connecttimeout of 10 seconds |
@jeroen Is it true that there are no defaults set by the curl package for the overall Also: is it true that the only way to control these is by setting them on the handle? |
Yes that sounds correct. The only defaults that the curl R package is setting are these: https://github.com/jeroen/curl/blob/master/src/handle.c#L124-L210
Yes that is correct. |
So I guess we were hitting the connect timeout at rstudio::conf. I think that's the main (only?) curl option we need to provide a way to increase during a WiFi fiasco. |
The connect timeout is set to a default of 10 sec. I don't think raising that will help. If the host has not responded after 10 sec, likely it is unreachable. If the wifi is connection is flaky because the network is overloaded, connections get dropped. This is of course beyond our control :) |
I am more optimistic that extending the timeout will help. At rstudio::conf we had overloaded internet -- but it technically worked. So I see above that @gaborcsardi uses 30 seconds for the connect timeout in async. |
Yeah, I think at the conf the bottleneck was at the local router that only allowed a finite number of connection at any time. But once you got a connection, you were good. So it was worth having a long connection timeout. But having that as a default can be annoying if the web server or app is down, because it will not timeout for a long time. I think for |
Lesson learned from rstudio::conf 2020.
If the internet is functional but slow,
use_course()
can timeout. It inherits the default timeout from curl.But I could possibly afford some way to set a longer timeout in an individual call or to do so globally via an env var or option.
Timeout can be set on the handle, i.e.
h <- new_handle(timeout = 10)
right around here:usethis/R/course.R
Line 208 in 4cae785
The text was updated successfully, but these errors were encountered: