Skip to content

Commit 7b5256e

Browse files
committed
feat(fortuna): Add timeout for all instrumented rpc calls
1 parent 6153eac commit 7b5256e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

apps/fortuna/src/eth_utils/traced_client.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use reqwest::Client;
2+
use std::time::Duration;
3+
use url::Url;
14
use {
25
crate::api::ChainId,
36
anyhow::Result,
@@ -11,7 +14,7 @@ use {
1114
metrics::{counter::Counter, family::Family, histogram::Histogram},
1215
registry::Registry,
1316
},
14-
std::{str::FromStr, sync::Arc},
17+
std::sync::Arc,
1518
tokio::{sync::RwLock, time::Instant},
1619
};
1720

@@ -114,8 +117,13 @@ impl TracedClient {
114117
url: &str,
115118
metrics: Arc<RpcMetrics>,
116119
) -> Result<Provider<TracedClient>> {
120+
let url: Url = url.try_into()?;
121+
let client = Client::builder()
122+
.timeout(Duration::from_secs(10))
123+
.build()
124+
.expect("Failed to create HTTP client");
117125
Ok(Provider::new(TracedClient {
118-
inner: Http::from_str(url)?,
126+
inner: Http::new_with_client(url, client),
119127
chain_id,
120128
metrics,
121129
}))

0 commit comments

Comments
 (0)