feat: improved msg for network timeouts#1961
Conversation
|
|
||
| fn handle_response_errors(err: reqwest::Error) -> io::Error { | ||
| if err.is_timeout() { | ||
| io::Error::new(io::ErrorKind::TimedOut, "Failed to download distribution due to network timeout. Try increasing UV_HTTP_TIMEOUT.") |
There was a problem hiding this comment.
It looks like Zanie suggested HTTP_TIMEOUT. Do you mind changing to HTTP_TIMEOUT, and displaying the current value too? This is great!
There was a problem hiding this comment.
Good point, I decided to use UV_HTTP_TIMEOUT for consitency with registry_client.rs first check (which seems to prefer UV_HTTP_TIMEOUT and HTTP_TIMEOUT last). I could also update that warn_user_once as part of this PR if we want to be fully consistent.
let timeout = env::var("UV_HTTP_TIMEOUT").or_else(|_| env::var("UV_REQUEST_TIMEOUT")).or_else(|_| env::var("HTTP_TIMEOUT")).and_then(|value| {
value.parse::<u64>()
.or_else(|_| {
// On parse error, warn and use the default timeout
warn_user_once!("Ignoring invalid value from environment for UV_REQUEST_TIMEOUT. Expected integer number of seconds, got \"{value}\".");
Ok(default_timeout)
})
}).unwrap_or(default_timeout);There was a problem hiding this comment.
I think UV_HTTP_TIMEOUT is good, it seems better not to recommend changing a value that other clients will respect unless you need to.
There was a problem hiding this comment.
Can we say how long the timeout is currently though?
|
Thanks for contributing! I'd really like to explore addressing this at its root too, it seems like our timeout is not correctly configured. Regarding testing, maybe we'd spin up a temporary webserver that just doesn't respond? That feels beyond the scope of this change though. A manual test should suffice for now. |
# Conflicts: # crates/uv-client/src/registry_client.rs
|
Thanks! |
Summary
Closes #1922
When a timeout occurs, it hints to the user to configure the
UV_HTTP_TIMEOUTenv var.Before
After
Test Plan
Wasn't sure if we'd want a test. If we do, is there a existing mechanism or preferred approach to force a timeout to occur in tests? Maybe set the timeout to 1 and add torch as an install check (although it's possible that could become flaky)?