emeraldpay / dshackle

Fault Tolerant Load Balancer for Ethereum and Bitcoin APIs
Apache License 2.0
308 stars 55 forks source link

Handle error and incorrect responses from upstreams #233

Open taxmeifyoucan opened 1 year ago

taxmeifyoucan commented 1 year ago

When user calls Dshackle with a wrong request and any upstream doesn't respond, Dshackle returns an error, e.g. code":-32002,"message":"No response or no available upstream... However, when it forwards the request to an upstream and receives any kind of text response, it seems to somehow use this data to respond to user. This often happens with remote/public upstreams, not when directly connected to a node.

For example, when Dshackle is pointed to an upstream which is behind another Dshackle instance and receives previously mentioned error as a response, it actually responds to user with incorrect and seemingly random values coming from this text.

Dshackle should be able to recognize an incorrect format of the response, detect there is an error and discard it as no response from the upstream.