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 Promise #10

Open
1 task done
MicahZoltu opened this issue Oct 6, 2017 · 1 comment
Open
1 task done

Unhandled Promise #10

MicahZoltu opened this issue Oct 6, 2017 · 1 comment

Comments

@MicahZoltu
Copy link

MicahZoltu commented Oct 6, 2017

Issue Type

Description

The method called here returns a promise, but that promise is then dropped on the floor. When a failure occurs in the method, this results in an unhandled rejection error in node with a threat to crash the application in future versions of node. I have argued with the node/chrome maintainers at length that this is an incorrect behavior and inappropriate usage of promises but ultimately they decided to prefer making node "easy for bad programmers" rather than "powerful for advanced users" and it doesn't look like they plan on changing this. Because of this, all promises in a library should either return up the stack to the end-user or should be capped with a catch(...) before they are dropped.

Steps to reproduce

  1. Instantiate a contract.
  2. Call a method on that contract.
  3. Have your Ethereum node return a failure like {"id":6604108303907,"jsonrpc":"2.0","result":"0x6864f52eba193e1b7d1b2eafddcf454dfb1568d756c5782d40efbc8c8857efbc","error":{"message":"VM Exception while processing transaction: invalid opcode","code":-32000}}

In my case, the error I get back looks like (though the error specifics shouldn't matter):

Error: [ethjs-provider-http] Invalid JSON RPC response from provider
    host: http://localhost:64891
    response:  ""
    responseURL: undefined
    status: 0
    statusText: 

Versions

  • Node/NPM: v8.5.0/5.3.0

Peanut Gallery

This whole problem would go away if the library used promises all the way down rather than just faking it half of the time and using callbacks the other half of the time. Also, if written in ES2017 you could use async/await which would make the code much easier to read.

MicahZoltu added a commit to MicahZoltu/ethjs-contract that referenced this issue Oct 6, 2017
Fixes ethjs#10.

Rather than intermixing callbacks and promises, this opts to just use promises all the way through.

Giant caveat: This means that the `query` passed in to the constructor _must_ support promises.  I personally think this is the right/sane thing to do, but if you want to continue to support callbacks you will need to solve this bug in a different way (e.g., swallow the promise result of `query[queryMethod](...)`).
@sathyamlokare
Copy link

sathyamlokare commented Mar 9, 2018

Error: [ethjs-provider-http] Invalid JSON RPC response from provider
host: https://rinkeby.infura.io/
response: ""
responseURL: undefined
status: 405
statusText: Method Not Allowed

I get this error when I do a sendTransaction how do i solve this ?

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

Successfully merging a pull request may close this issue.

2 participants