-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: sozo migrate hanging #2441
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
@@ -12,6 +14,7 @@ | |
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}; | ||
|
@@ -147,7 +150,19 @@ | |
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()) | ||
}, | ||
glihm marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+153
to
+163
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can be simplified to let timeout_duration = Duration::from_secs(5);
tokio::time::timeout(timeout_duration, provider.spec_version()).await?; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ha nice way less verbose! |
||
}?; | ||
|
||
trace!(spec_version); | ||
|
||
if !is_compatible_version(&spec_version, RPC_SPEC_VERSION)? { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the current timeout by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forever
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm would be better if we can introduce this timeout in the
Provider
implementation itself. so that it'd be applied to all request.i assume the current approach is to just add the timeout on the very first provider request for a command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, would be here @notV4l:
dojo/bin/sozo/src/commands/options/starknet.rs
Line 27 in 21ec45e