Skip to content

Commit 6474c70

Browse files
authored
feat(fortuna): Add timeout for rpc calls (#2633)
* feat(fortuna): Add timeout for all instrumented rpc calls * format imports + bump
1 parent 6153eac commit 6474c70

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

apps/fortuna/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/fortuna/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fortuna"
3-
version = "7.5.1"
3+
version = "7.5.2"
44
edition = "2021"
55

66
[lib]

apps/fortuna/src/eth_utils/traced_client.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ use {
1111
metrics::{counter::Counter, family::Family, histogram::Histogram},
1212
registry::Registry,
1313
},
14-
std::{str::FromStr, sync::Arc},
14+
reqwest::Client,
15+
std::{sync::Arc, time::Duration},
1516
tokio::{sync::RwLock, time::Instant},
17+
url::Url,
1618
};
1719

1820
#[derive(Debug, Clone, PartialEq, Eq, Hash, EncodeLabelSet)]
@@ -114,8 +116,13 @@ impl TracedClient {
114116
url: &str,
115117
metrics: Arc<RpcMetrics>,
116118
) -> Result<Provider<TracedClient>> {
119+
let url: Url = url.try_into()?;
120+
let client = Client::builder()
121+
.timeout(Duration::from_secs(10))
122+
.build()
123+
.expect("Failed to create HTTP client");
117124
Ok(Provider::new(TracedClient {
118-
inner: Http::from_str(url)?,
125+
inner: Http::new_with_client(url, client),
119126
chain_id,
120127
metrics,
121128
}))

0 commit comments

Comments
 (0)