Skip to content

Commit

Permalink
Avoid panicking when the resolver thread encounters a closed channel (#…
Browse files Browse the repository at this point in the history
…6182)

Closes #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`.
  • Loading branch information
zanieb authored Aug 18, 2024
1 parent 615dda0 commit baf17be
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/uv-resolver/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,17 @@ impl<Provider: ResolverProvider, InstalledPackages: InstalledPackagesProvider>
.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();

let resolve_fut = async move { rx.await.map_err(|_| ResolveError::ChannelClosed) };

// Wait for both to complete.
let ((), resolution) = tokio::try_join!(requests_fut, resolve_fut)?;

state.on_complete();
resolution
}
Expand Down

0 comments on commit baf17be

Please sign in to comment.