From c520c0ddb6f36ef2be94d9c61ee4be9c525d6ae9 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Sun, 18 Aug 2024 09:20:58 -0500 Subject: [PATCH] Avoid panicking when the resolver thread encounters a closed channel --- 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 }