-
Notifications
You must be signed in to change notification settings - Fork 265
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
[Bug] Blocks on anvil node hang after some time #1078
Comments
When I start reading stdout through BufReader everything works as intended. let mut anvil = Anvil::new().block_time(1).try_spawn()?;
let provider = ProviderBuilder::new()
.on_builtin(&anvil.ws_endpoint())
.await?;
//workaroud:
let child = anvil.child_mut();
let stdout = child.stdout.take().unwrap();
tokio::task::spawn(async {
let mut reader = BufReader::new(stdout);
loop {
let mut line = String::new();
reader.read_line(&mut line).unwrap();
}
});
let block_subscription = provider.subscribe_blocks().await?;
let mut block_stream = block_subscription.into_stream();
while let Some(block) = block_stream.next().await {
let block_number = block.header.number.expect("failed to get block number");
tracing::info!("block_number = {block_number}");
} |
To speed up reproduction use let anvil = Anvil::new().block_time_f64(0.001).try_spawn()?; |
Very similar problem, but in foundry foundry-rs/foundry#3414 https://doc.rust-lang.org/std/process/struct.Stdio.html#method.piped
|
Component
node-bindings, provider, pubsub
What version of Alloy are you on?
alloy v0.1.4
anvil v0.2.0 (e903484 2024-07-19T00:35:00.564315108Z)
Operating System
Linux
Describe the bug
Minimal example:
git clone git@github.com:StackOverflowExcept1on/alloy-anvil-bug.git cd alloy-anvil-bug cargo run --release
The text was updated successfully, but these errors were encountered: