-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RPC error middleware for json-rpc-engine #4199
Conversation
68331d8
to
73faf3a
Compare
When I try the reproduction step from #3847 I still get an anonymous error:
That just means it doesn't fix that issue yet. I couldn't figure out how to reproduce #3054, I'm fine closing it. #1477 reproduction steps didn't throw an error for me, so I couldn't verify the fix. #974 still gave returned an unreadable error message to the dapp:
Is it possible I built wrong or something? Do you get a message when calling that top method in browser console? |
Re: #3487: We were properly logging the RPC error object to the console, but that error object wasn't populated with a required
|
To close #3487 at least, we should pass the error message all the way back to the Dapp that made the call. |
Two options:
Let me know which you prefer, I'm happy to merge this if we keep that issue open. |
@danfinlay thanks for the review. You were right, I was logging the errors instead of augmenting the actual object that's passed up the chain to a dapp. This should be ready for another review when you have a chance. I verified that the returned error object now contains a valid |
Thank You |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you, this is going to make a lot of devs happy. Maybe add a changelog entry to let them know?
Thanks @danfinlay, |
Oh wow, test-deps failing for node security. How is this not an issue on |
ef71f7f
to
2c0e80c
Compare
99aead7
to
06ddb79
Compare
06ddb79
to
ce28344
Compare
@danfinlay It looks like |
this seems like it should go into |
@kumavis Would you prefer I close this and submit a PR against |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good solution to me, I don't think this should be in core json-rpc-engine
, since it's compensating for an infura quirk. Maybe we could call it an infura-error-middleware
.
This PR implements new
json-rpc-engine
-compatible middleware intended to log consistent, human-readable RPC error messages.Even though the JSON-RPC 2.0 specification documents
message
as a required property on the RPC error object, it'sundefined
for most standard RPC error codes when hitting the latest Infura provider. This middleware logs predefined messages based on RPC error codes by default; it can also be configured to use provider-supplied error messages if they exist and to only fall back on predefined messages. The original RPC error object is also always logged regardless of middleware configuration so any additional errordata
can still be inspected, such as solidity compilation information.Resolves #3487
Resolves #3054
Resolves #1477
Resolves #794