uv: Add support for retrying connection failures
Tested with uv 0.1.41
While looking for workarounds to https://github.com/astral-sh/uv/issues/3512, I experimented with using --no-cache.
In our case, this actually increased the failure rate, as we use a local artifactory based pypi mirror which appears rate limited.
Using the same bash script as in the linked issue but with --no-cache added, and with significantly more packages, we began observing instances where the artifactory server would be overwhelmed and UV would fail with connection reset by peer.
Under pip, this was also reproducible though it required a larger number of simultaneous processes (~80), but rather that failing outright PIP would retry connection failures. Please add (ideally configurable) support for retrying connection failures when downloading or querying indexes
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 8
- Comments: 50 (32 by maintainers)
Commits related to this issue
- Log transient request failures We retry several kinds of request failures, but it's often unclear whether a request was retried or not (https://github.com/astral-sh/uv/issues/3514#issuecomment-210548... — committed to astral-sh/uv by konstin 2 years ago
- Log transient network request failures (#3933) We retry several kinds of network request failures, but it's often unclear whether a request was retried or not (https://github.com/astral-sh/uv/issue... — committed to astral-sh/uv by konstin 2 years ago
- Add retries to error message As a user or developer, it is hard to tell whether a request failed randomly and was not retried, or whether it failed even with retries (e.g. https://github.com/astral-s... — committed to konstin/reqwest-middleware by konstin 2 years ago
- chore(ci): workaround to retry `error decoding response body` from uv (#3889) This PR uses a shell wrapper to check if the `error decoding response body` error message is in the uv stderr and retry i... — committed to deepmodeling/deepmd-kit by njzjz 2 years ago
- chore(ci): workaround to retry `error decoding response body` from uv (#3889) This PR uses a shell wrapper to check if the `error decoding response body` error message is in the uv stderr and retry i... — committed to deepmodeling/deepmd-kit by njzjz 2 years ago
- chore(ci): workaround to retry `error decoding response body` from uv (#3889) This PR uses a shell wrapper to check if the `error decoding response body` error message is in the uv stderr and retry i... — committed to deepmodeling/deepmd-kit by njzjz 2 years ago
- Add retries to error message As a user or developer, it is hard to tell whether a request failed randomly and was not retried, or whether it failed even with retries (e.g. https://github.com/astral-s... — committed to konstin/reqwest-middleware by konstin 2 years ago
- chore(ci): workaround to retry `error decoding response body` from uv (#3889) This PR uses a shell wrapper to check if the `error decoding response body` error message is in the uv stderr and retry i... — committed to njzjz/deepmd-kit by njzjz 2 years ago
- Show when we retried requests In #3514 and #2755, users had intermittent network errors, but it was not always clear whether we had already retried these requests or not. Building upon https://github... — committed to astral-sh/uv by konstin 2 years ago
- Show when we retried requests In #3514 and #2755, users had intermittent network errors, but it was not always clear whether we had already retried these requests or not. Building upon https://github... — committed to astral-sh/uv by konstin 2 years ago
- Show when we retried requests (#4725) In #3514 and #2755, users had intermittent network errors, but it was not always clear whether we had already retried these requests or not. Building upon https:... — committed to astral-sh/uv by konstin 2 years ago
- chore(ci): workaround to retry `error decoding response body` from uv (#3889) This PR uses a shell wrapper to check if the `error decoding response body` error message is in the uv stderr and retry i... — committed to deepmodeling/deepmd-kit by njzjz 2 years ago
- Retry on connection reset network errors (#4960) See helpful discussion at https://github.com/seanmonstar/reqwest/issues/1602#issuecomment-1220990725 and https://github.com/astral-sh/uv/issues/3514... — committed to astral-sh/uv by zanieb 2 years ago
- Download wheel to disk when streaming unzip failed with HTTP streaming error (#5094) ## Summary Workaround the `stream_wheel` not retry issue [found](https://github.com/astral-sh/uv/issues/3514#i... — committed to astral-sh/uv by messense 2 years ago
- Retry on incomplete body This is an attempt to add https://github.com/astral-sh/uv/issues/3514#issuecomment-2253562096 to retrying. Relevant hyper code: * https://github.com/hyperium/hyper/blob/15cd... — committed to astral-sh/uv by konstin 2 years ago
- Retry on incomplete body (#5555) This is an attempt to add https://github.com/astral-sh/uv/issues/3514#issuecomment-2253562096 to retrying. Relevant hyper code: * https://github.com/hyperium/h... — committed to astral-sh/uv by konstin 2 years ago
- chore(ci): workaround to retry `error decoding response body` from uv (#3889) This PR uses a shell wrapper to check if the `error decoding response body` error message is in the uv stderr and retry i... — committed to mtaillefumier/deepmd-kit by njzjz 2 years ago
Happy to report
uvv0.2.26 runs smoothly for me, no more failures when downloading wheels.I think the issue is with
stream_wheel, if I change https://github.com/astral-sh/uv/blob/9a44bc1d3567e0a2ba31675bc35c50392fc2f5ad/crates/uv-distribution/src/distribution_database.rs#L211 to remove theifto unconditional trydownload_wheelwhenstream_wheelfails withExtracterror,uvcorrectly retries.so my guess is that
reqwest-retrydoes not support retrying streaming response? Can we have a config/option/env var to forcedownload_wheel?All the errors were related to running
uv pip compile, so it was only trying to collect metadata? I don’t have any additional output than what I posted.The index is https://pypi.org/, but the network involves a Palo Alto firewall that will be decrypting and encrypting traffic, and it seems occasionally this will just fail (either kill the connection or send an empty body).
I’ve seen a regression in this recently, in the last few days, using the latest version of uv, I’ve started seeing:
I run again and it’s fine, but I thought uv was now retrying these low level network errors?
It could of course just be my corporate network environment getting worse, worth reporting a new issue?
I think https://github.com/astral-sh/uv/pull/5555 should fix this.
@charliermarsh These failures happened with uv 0.2.29 (you can check the link to our GitHub Actions to see some non-verbose logs). I’m pretty sure I’ve seen it on earlier versions as well.
Haven’t seen it yet with 0.2.30, but I can post here if I do see it. But I don’t believe 0.2.30 contains any fixes related to this issue.
If it helps, I can set our CI to verbose to get better logs on this issue?
I’m unable to reproduce in my end either, curious if this resolves other’s issues as well.
Maybe because the unzip error causing an early error return?
Found this, will try with that env var
I’ll take this build for a spin on my testing farm. The networking issues I was suffering were infrequent so I won’t be able to say for certain but if it shows up I’ll let you know
I put up a patch at #4960 if anyone wants to give it a try.
Judging from the code,
reqwest-retrysimply won’t retry body errors.I’m using uv 0.2.23, the error message is
Hi @aybidi — we think this is important to address but haven’t started working on a fix yet. If anyone is willing to investigate and contribute in the meantime I’m happy to review.
I assume those retries don’t apply to streaming operations. Like, they apply to the initial request itself, but probably not the entirety of reading from the stream? We can fix this by adding our own retry around download operations.
Looking at it again, it does seem like it would retry on resets, see retryable_strategy.rs#L192