Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

PubSubItem deserialize #2578

Merged
merged 2 commits into from
Sep 3, 2023
Merged

PubSubItem deserialize #2578

merged 2 commits into from
Sep 3, 2023

Conversation

AmazingGame
Copy link
Contributor

…ng in errors.

json example:
"{"jsonrpc":"2.0","id":268,"result":null,"error":{"code":-32000,"message":"tracing failed: fee cap less than block base fee: address 0x4a4BA8a759e7217a1ff38749Aa6E73564C1D8a01, gasFeeCap: 11470668621 baseFee: 11484931392"}}"

If the json response contains both result and errors, it's better to return errors instead of "response must be a success/error or notification object"

Also, after returning "de::Error::custom", in

  pub async fn handle_text(&mut self, t: String) -> Result<(), WsClientError> {
         trace!(text = t, "Received message");
         match serde_json::from_str(&t) {
             Ok(item) => {
                 trace!(%item, "Deserialized message");
                 let res = self.handler.unbounded_send(item);
                 if res.is_err() {
                     return Err(WsClientError::DeadChannel)
                 }
             }
             Err(e) => {
                 error!(e = %e, "Failed to deserialize message");
             }
         }
         Ok(())
     }

An error should be returned instead of just printing the error, which would cause the request to wait indefinitely.

PR Checklist
[x ] Added Tests
[x ] Added Documentation
[x ] Breaking changes

Copy link
Collaborator

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, waiting on @prestwich

@DaniPopes DaniPopes merged commit 1052c93 into gakonst:master Sep 3, 2023
19 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants