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

fix(ws): propagate deserialization errors upstream + infura quickfix #827

Merged
merged 5 commits into from
Jan 24, 2022

Conversation

erwanor
Copy link
Contributor

@erwanor erwanor commented Jan 24, 2022

Motivation

Deserializing a poorly formatted Incoming message over websocket fails silently. This is why #684 was mysteriously failing when using a wss provider from Infura. Infura streams back messages with an all capitalized JSONRPC field which serde chokes over when deserializing into a Notification.

Solution

Propagate deserialization errors through ClientError.

I think it's fair to support Infura idiosyncrasies considering they're such a prominent provider. With that said, the stable solution is probably using something like #[serde(case_insensitive)] (see serde-rs/serde#1902) although this should come with an overhead. In the meantime, this fixes the issue for Infura wss users.

PR Checklist

  • Added Tests
  • Added Documentation
  • Updated the changelog

Infura streams notifications with jsonrpc all capitalized. This fails to
deserialize on our end because serde expect a precise match ressembling
the Notification jsonrpc field.

Fixes gakonst#684.
Copy link
Owner

@gakonst gakonst left a comment

Choose a reason for hiding this comment

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

this is quite crazy, good find, thank you!

@gakonst gakonst merged commit f9f77e8 into gakonst:master Jan 24, 2022
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