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

Improve error handling in RPC #4726

Open
gumb0 opened this issue Dec 28, 2017 · 2 comments
Open

Improve error handling in RPC #4726

gumb0 opened this issue Dec 28, 2017 · 2 comments

Comments

@gumb0
Copy link
Member

gumb0 commented Dec 28, 2017

  1. Exceptions should be caught in RPC methods implementation (and re-thrown as jsonrpc::JsonRpcException) in order to generate error response and not just crash.
    At least in these methods I don't see proper handling of possible errors:
admin_eth_findBlock // invalid block hash will throw
admin_eth_newAccount // I think writing file on disk might throw
admin_addPeer // incorrect node address will throw
debug_traceBlock // will throw if RLP is incorrect hex string
debug_traceBlockByHash
personal_unlockAccount

1a. Many methods could be improved with better error messages (many report just "invalid params" for any possible error).

  1. Sending RPC request with invalid json in body on Linux through HTTP results for me in curl: (52) Empty reply from server and Request timed out: timeout('timed out',) in jsonrpcproxy log.
    On Windows curl just hangs never getting the response.

It should generate proper response with error message for this case.

@Manugal
Copy link

Manugal commented Mar 28, 2018

Hi @gumb0,
I am a new contributor and I'd like to take care of this issue. Could you give me some guidance on how to test the methods listed above? I have already implemented exception handling on some of them, but I need to test.

@gumb0
Copy link
Member Author

gumb0 commented Mar 29, 2018

Hi @Manugal, thank you for your interest!
There's no good way to write autotests for RPC methods at the moment, but you should be able to manually check it by starting eth (without arguments it will just start the sync with the main net) and then using ethereum-console (https://github.com/ethereum/ethereum-console) to connect to the node and send RPC requests.

So something like this should work

$ npm install -g ethereum-console
$ ethconsole
> web3.debug.traceBlockByHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3")

There were some changes in ethconsole lately, and I haven't tried it with a latest version, so let me know if it's not working at all and you need some assistance (maybe in Gitter it would be more convenient)

Note also: it's better to submit your changes as a PR as early as possible, than trying to finish big chunk of work first.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants