Skip to content

Commit

Permalink
[sui-proxy] set 10s timeout for bridge metrics key query (#19527)
Browse files Browse the repository at this point in the history
## Description 

some bridge endpoints take very long to return and eventually fail, this
slows down the key fetching process
  • Loading branch information
johnjmartin authored Sep 24, 2024
1 parent ec8e921 commit b39e43d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions crates/sui-proxy/src/peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ fn extract(
}
})
}

async fn extract_bridge(
summary: BridgeSummary,
metrics_keys: MetricsPubKeys,
Expand All @@ -356,7 +357,10 @@ async fn extract_bridge(
});
}

let client = reqwest::Client::builder().build().unwrap();
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(10))
.build()
.unwrap();
let committee_members = summary.committee.members.clone();
let results: Vec<_> = stream::iter(committee_members)
.filter_map(|(_, cm)| {
Expand Down Expand Up @@ -429,6 +433,11 @@ async fn extract_bridge(
// Successfully fetched the key, update the cache
let mut metrics_keys_write = metrics_keys.write().unwrap();
metrics_keys_write.insert(url_str.clone(), pubkey.clone());
debug!(
url_str,
public_key = ?pubkey,
"Successfully added bridge peer to metrics_keys"
);
pubkey
}
Err(error) => {
Expand Down Expand Up @@ -479,7 +488,7 @@ fn fallback_to_cached_key(
},
))
} else {
error!(
warn!(
url_str,
"Failed to fetch public key and no cached key available"
);
Expand Down

0 comments on commit b39e43d

Please sign in to comment.