From baf17bee861fe07121b00a4285564bc85529ab9f Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Sun, 18 Aug 2024 16:04:05 -0500 Subject: [PATCH] Avoid panicking when the resolver thread encounters a closed channel (#6182) Closes https://github.com/astral-sh/uv/issues/6167 We've been seeing intermittent failures in CI, which we thought were unexpected HTTP 401s but it actually looks like a panic when handling an expected HTTP error. I believe the problem is that an early client error can cause the channel to close and we crash when we unwrap the `send`. --- crates/uv-resolver/src/resolver/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/uv-resolver/src/resolver/mod.rs b/crates/uv-resolver/src/resolver/mod.rs index 3bb311a004ec..af435f8719ff 100644 --- a/crates/uv-resolver/src/resolver/mod.rs +++ b/crates/uv-resolver/src/resolver/mod.rs @@ -271,7 +271,9 @@ impl .name("uv-resolver".into()) .spawn(move || { let result = solver.solve(index_locations, request_sink); - tx.send(result).unwrap(); + + // This may fail if the main thread returned early due to an error. + let _ = tx.send(result); }) .unwrap(); @@ -279,6 +281,7 @@ impl // Wait for both to complete. let ((), resolution) = tokio::try_join!(requests_fut, resolve_fut)?; + state.on_complete(); resolution }