Skip to content

Commit

Permalink
fix: don't wrap rpc error in DisconnectedWillReconnect in reconnectin…
Browse files Browse the repository at this point in the history
…g rpc client (#1904)

* fix: don't wrap rpc err in DisconnectedWillRecon

* add clarifying comment

* fix no-std-test build

* fix no-std-test build v2
  • Loading branch information
niklasad1 authored Jan 24, 2025
1 parent dff4dab commit 39507c7
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 1,171 deletions.
14 changes: 12 additions & 2 deletions subxt/src/backend/rpc/reconnecting_rpc_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,13 @@ impl RpcClientT for RpcClient {
async {
self.request(method.to_string(), params)
.await
.map_err(|e| SubxtRpcError::DisconnectedWillReconnect(e.to_string()))
.map_err(|e| match e {
Error::DisconnectedWillReconnect(e) => {
SubxtRpcError::DisconnectedWillReconnect(e.to_string())
}
Error::Dropped => SubxtRpcError::ClientError(Box::new(e)),
Error::RpcError(e) => SubxtRpcError::ClientError(Box::new(e)),
})
}
.boxed()
}
Expand All @@ -449,7 +455,11 @@ impl RpcClientT for RpcClient {
SubscriptionId::Str(s) => s.to_string(),
};
let stream = sub
.map_err(|e| SubxtRpcError::DisconnectedWillReconnect(e.to_string()))
// NOTE: The stream emits only one error `DisconnectWillReconnect if the connection was lost
// and safe to wrap it in a `SubxtRpcError::DisconnectWillReconnect` here
.map_err(|e: DisconnectedWillReconnect| {
SubxtRpcError::DisconnectedWillReconnect(e.to_string())
})
.boxed();

Ok(RawRpcSubscription {
Expand Down
Loading

0 comments on commit 39507c7

Please sign in to comment.