Skip to content

Commit

Permalink
fix: sozo migrate hanging
Browse files Browse the repository at this point in the history
  • Loading branch information
notV4l committed Sep 17, 2024
1 parent 21ec45e commit c34916e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion bin/sozo/src/commands/migrate.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::time::Duration;

use anyhow::{anyhow, Context, Result};
use clap::{Args, Subcommand};
use dojo_utils::TxnConfig;
Expand All @@ -12,6 +14,7 @@ use starknet::core::types::{BlockId, BlockTag, Felt, StarknetError};
use starknet::core::utils::parse_cairo_short_string;
use starknet::providers::jsonrpc::HttpTransport;
use starknet::providers::{JsonRpcClient, Provider, ProviderError};
use tokio::time;
use tracing::trace;

use super::options::account::{AccountOptions, SozoAccount};
Expand Down Expand Up @@ -147,7 +150,19 @@ pub async fn setup_env<'a>(
let provider = starknet.provider(env)?;
trace!(?provider, "Provider initialized.");

let spec_version = provider.spec_version().await?;
let get_spec_version = provider.spec_version();
let timeout = time::sleep(Duration::from_secs(5));
tokio::pin!(timeout);

let spec_version = tokio::select! {
_ = &mut timeout => {
Err(anyhow!( "Unable to connect to RPC provider: timeout, might be cors issue"))
},
version = get_spec_version => {
Ok(version.unwrap())
},
}?;

Check warning on line 164 in bin/sozo/src/commands/migrate.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/commands/migrate.rs#L164

Added line #L164 was not covered by tests

trace!(spec_version);

if !is_compatible_version(&spec_version, RPC_SPEC_VERSION)? {
Expand Down

0 comments on commit c34916e

Please sign in to comment.