Skip to content

[json-rpc-engine] Improve handling for unexpected middleware error types, align error types to use JsonRpcEngineCallbackError #4027

Description

@MajorLift

Motivation

Currently, JsonRpcEngine handles non-JSON-RPC errors thrown from middleware by passing them into end callbacks without validation or serialization.

Fixing this is necessary to take full advantage of the provider alignment technical proposals, as JsonRpcEngine is the call site for the provider methods. A more accurately typed JsonRpcEngine would enable us to make potential typing improvements to the providers as well.

Explanation

The code for handling these errors suppresses valid errors by using type assertions (as JsonRpcEngineCallbackError), despite their being no guarantee that the thrown errors will be of that type. These assertions (currently marked by TODO comments) should be removed and replaced with type-safe code.

We should align error types used throughout middleware the chain with the JsonRpcEngineCallbackError type. This may involve coming up with a scheme for lossless serialization of errors that explicitly preserves information that is expected by JsonRpcEngine.

References

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions