Skip to content

Commit f88c0ff

Browse files
authored
fix(firehose): Add retry around firehose connection test (#4754)
1 parent 6cd8742 commit f88c0ff

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

node/src/chain.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use graph::prelude::{anyhow, tokio};
1212
use graph::prelude::{prost, MetricsRegistry};
1313
use graph::slog::{debug, error, info, o, Logger};
1414
use graph::url::Url;
15+
use graph::util::futures::retry;
1516
use graph::util::security::SafeDisplay;
1617
use graph_chain_ethereum::{self as ethereum, EthereumAdapterTrait, Transport};
1718
use std::collections::{btree_map, BTreeMap};
@@ -329,12 +330,21 @@ where
329330
logger, "Connecting to Firehose to get chain identifier";
330331
"provider" => &endpoint.provider.to_string(),
331332
);
332-
match tokio::time::timeout(
333-
NET_VERSION_WAIT_TIME,
334-
endpoint.genesis_block_ptr::<M>(&logger),
335-
)
336-
.await
337-
.map_err(Error::from)
333+
334+
let retry_endpoint = endpoint.clone();
335+
let retry_logger = logger.clone();
336+
let req = retry("firehose startup connection test", &logger)
337+
.no_limit()
338+
.no_timeout()
339+
.run(move || {
340+
let retry_endpoint = retry_endpoint.clone();
341+
let retry_logger = retry_logger.clone();
342+
async move { retry_endpoint.genesis_block_ptr::<M>(&retry_logger).await }
343+
});
344+
345+
match tokio::time::timeout(NET_VERSION_WAIT_TIME, req)
346+
.await
347+
.map_err(Error::from)
338348
{
339349
// An `Err` means a timeout, an `Ok(Err)` means some other error (maybe a typo
340350
// on the URL)

0 commit comments

Comments
 (0)