Avoid panics due to reads on failed requests (#17098)

Fixes https://github.com/astral-sh/uv/issues/17090, specifically the
panic, not the upstream bug.
This commit is contained in:
konsti 2025-12-12 18:02:49 +01:00 committed by GitHub
parent 7ad441a0bd
commit 3e80b10272
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 1 deletions

View File

@ -297,7 +297,13 @@ impl ProgressReporter {
return;
};
state.lock().unwrap().bars[&id].inc(bytes);
// Avoid panics due to reads on failed requests.
// https://github.com/astral-sh/uv/issues/17090
// TODO(konsti): Add a debug assert once https://github.com/seanmonstar/reqwest/issues/2884
// is fixed
if let Some(bar) = state.lock().unwrap().bars.get(&id) {
bar.inc(bytes);
}
}
fn on_request_complete(&self, direction: Direction, id: usize) {