File tree Expand file tree Collapse file tree 3 files changed +111
-1171
lines changed
subxt/src/backend/rpc/reconnecting_rpc_client Expand file tree Collapse file tree 3 files changed +111
-1171
lines changed Original file line number Diff line number Diff line change @@ -427,7 +427,13 @@ impl RpcClientT for RpcClient {
427427 async {
428428 self . request ( method. to_string ( ) , params)
429429 . await
430- . map_err ( |e| SubxtRpcError :: DisconnectedWillReconnect ( e. to_string ( ) ) )
430+ . map_err ( |e| match e {
431+ Error :: DisconnectedWillReconnect ( e) => {
432+ SubxtRpcError :: DisconnectedWillReconnect ( e. to_string ( ) )
433+ }
434+ Error :: Dropped => SubxtRpcError :: ClientError ( Box :: new ( e) ) ,
435+ Error :: RpcError ( e) => SubxtRpcError :: ClientError ( Box :: new ( e) ) ,
436+ } )
431437 }
432438 . boxed ( )
433439 }
@@ -449,7 +455,11 @@ impl RpcClientT for RpcClient {
449455 SubscriptionId :: Str ( s) => s. to_string ( ) ,
450456 } ;
451457 let stream = sub
452- . map_err ( |e| SubxtRpcError :: DisconnectedWillReconnect ( e. to_string ( ) ) )
458+ // NOTE: The stream emits only one error `DisconnectWillReconnect if the connection was lost
459+ // and safe to wrap it in a `SubxtRpcError::DisconnectWillReconnect` here
460+ . map_err ( |e : DisconnectedWillReconnect | {
461+ SubxtRpcError :: DisconnectedWillReconnect ( e. to_string ( ) )
462+ } )
453463 . boxed ( ) ;
454464
455465 Ok ( RawRpcSubscription {
You can’t perform that action at this time.
0 commit comments