mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-25 06:40:03 +00:00
fix(gh_api_client): remote client should never being shared everywhere bacause the underlying connection pool will be reused. (#1930)
The client pool contains connections associated with a runtime when the runtime closes, the client may panic at seeing the connection disappear "abruptly". Reported-by: https://archriscv.felixc.at/.status/log.htm?url=logs/cargo-binstall/cargo-binstall-1.8.0-1.log Link: https://github.com/seanmonstar/reqwest/issues/1148
This commit is contained in:
parent
61c9231401
commit
5069cb6638
1 changed files with 8 additions and 15 deletions
|
@ -327,7 +327,6 @@ impl GhApiClient {
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use compact_str::{CompactString, ToCompactString};
|
use compact_str::{CompactString, ToCompactString};
|
||||||
use once_cell::sync::OnceCell;
|
|
||||||
use std::{env, num::NonZeroU16, time::Duration};
|
use std::{env, num::NonZeroU16, time::Duration};
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
use tracing::subscriber::set_global_default;
|
use tracing::subscriber::set_global_default;
|
||||||
|
@ -506,20 +505,14 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_remote_client() -> remote::Client {
|
fn create_remote_client() -> remote::Client {
|
||||||
static CLIENT: OnceCell<remote::Client> = OnceCell::new();
|
remote::Client::new(
|
||||||
|
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")),
|
||||||
CLIENT
|
None,
|
||||||
.get_or_init(|| {
|
NonZeroU16::new(300).unwrap(),
|
||||||
remote::Client::new(
|
1.try_into().unwrap(),
|
||||||
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")),
|
[],
|
||||||
None,
|
)
|
||||||
NonZeroU16::new(300).unwrap(),
|
.unwrap()
|
||||||
1.try_into().unwrap(),
|
|
||||||
[],
|
|
||||||
)
|
|
||||||
.unwrap()
|
|
||||||
})
|
|
||||||
.clone()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mark this as an async fn so that you won't accidentally use it in
|
/// Mark this as an async fn so that you won't accidentally use it in
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue