[json-rpc-engine] Improve handling for unexpected middleware error types, align error types to use JsonRpcEngineCallbackError
#4027
Labels
JsonRpcEngineCallbackError
#4027
Motivation
Currently,
JsonRpcEngine
handles non-JSON-RPC errors thrown from middleware by passing them intoend
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 typedJsonRpcEngine
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 byJsonRpcEngine
.References
json-rpc-engine
: Replace use ofany
with proper types (non-test files only) #3720JsonRpcEngine
classThe text was updated successfully, but these errors were encountered: