Skip to content

Commit

Permalink
fix: ignore send error if no subscribers
Browse files Browse the repository at this point in the history
  • Loading branch information
msgmaxim committed Oct 11, 2023
1 parent 8a706ba commit 3a8b2ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 8 additions & 1 deletion api/bin/chainflip-ingress-egress-tracker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,14 @@ async fn main() -> anyhow::Result<()> {
}
}
});
let server = ServerBuilder::default().build("0.0.0.0:13337".parse::<SocketAddr>()?).await?;
let server = ServerBuilder::default()
// It seems that if the client doesn't unsubscribe correctly, a "connection"
// won't be released, and we will eventually reach the limit, so we increase
// as a way to mitigate this issue.
// TODO: ensure that connections are always released
.max_connections(1000)
.build("0.0.0.0:13337".parse::<SocketAddr>()?)
.await?;
let mut module = RpcModule::new(());
module.register_async_method("status", move |arguments, _context| {
let cache = cache.clone();
Expand Down
6 changes: 5 additions & 1 deletion api/bin/chainflip-ingress-egress-tracker/src/witnessing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ pub(super) fn start(
move |call: state_chain_runtime::RuntimeCall, _epoch_index| {
let witness_sender = witness_sender.clone();
async move {
witness_sender.send(call).unwrap();
// Send may fail if there aren't any subscribers,
// but it is safe to ignore the error.
if let Ok(n) = witness_sender.send(call) {
tracing::info!("Broadcasting witnesser call to {} subscribers", n);
}
}
}
};
Expand Down

0 comments on commit 3a8b2ac

Please sign in to comment.