Skip to content
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

Unhandled AssertionError on the RPC endpoint #41

Closed
gdassori opened this issue May 15, 2021 · 2 comments
Closed

Unhandled AssertionError on the RPC endpoint #41

gdassori opened this issue May 15, 2021 · 2 comments

Comments

@gdassori
Copy link
Contributor

gdassori commented May 15, 2021

The bcurl API raises an assertion error when an empty method is passed to the RPC execute method (https://github.com/bcoin-org/bcurl/blob/master/lib/client.js#L310).

The way the execute is used in the hsd and hsw client (super().execute) throw this bad exception right as a client response, when passing an empty method to the rpc command:

$ ./bin/hsd-cli rpc
AssertionError [ERR_ASSERTION]: Assertion failed.

This could be both a problem of bcurl, that doesn't throw an RPCError exception, or of the hs-client, that should catch the raw assertion and throw the error.

Knowing nothing, I tend to think that bcurl developers thought the execute method as private.

Intially I thought that a way to fix this could be to call the super().execute() inside a try\catch, and raise an RPCError.. but the RPCError is not exported by the client module, so I went into a loop and back to think as a bcurl "issue" (at least the dependency should be changed to export the class).

What do you think?

@pinheadmz
Copy link
Member

pinheadmz commented May 17, 2021

Seems like we should be able to catch this mistake further up, maybe throwing an error in hsd-cli itself here if method is null:

const method = this.argv.shift();

and in hsw-cli here:

const method = this.argv.shift();

@pinheadmz
Copy link
Member

Closed by #42

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

No branches or pull requests

2 participants