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

HttpProvider promise doesn't resolve on invalid RPC endpoint. #2396

Closed
kelsos opened this issue Feb 20, 2019 · 1 comment · Fixed by #2414
Closed

HttpProvider promise doesn't resolve on invalid RPC endpoint. #2396

kelsos opened this issue Feb 20, 2019 · 1 comment · Fixed by #2414
Labels
Bug Addressing a bug

Comments

@kelsos
Copy link

kelsos commented Feb 20, 2019

All issues which aren't created with this template will get immediately closed.

This happens on an Angular 7 project, I am not sure if this issue also affects other frameworks or if it is some combination with the dependencies that Angular pulls.

After some debugging (that was made harder due to zone.js), I found out that when a net::ERR_NAME_NOT_RESOLVED or an net::ERR_CONNECTION_REFUSED error will happen
request.onreadystatechange will get called with request.readyState === 4 && request.status === 0.
Since there is no handling of this case the promise will not resolve at all.

https://github.com/ethereum/web3.js/blob/89ee348a9758362e994ef2d8625f8aef46c61b91/packages/web3-providers/src/providers/HttpProvider.js#L142

Expected behavior

Promise should reject when the connection is refused or DNS fails to resolve.

Actual behavior

The promise never resolves/rejects.

Steps to reproduce the behavior

  1. Set an invalid rpc endpoint url on the HttpProvider. It can be either an url of of something that is not an rpc endpoint or and invalid url that dns cannot resolve.
  2. Attempt to get the chain id await this.web3.eth.net.getId();

Error Logs

Versions

[NPM, Node, Web3.js, OS, device...]

  • npm: '6.4.1'
  • node: v10.13.0
  • web3.js: 1.0.0-beta.46

Chrome and Firefox (Linux)

@kelsos kelsos changed the title HttpProvider promise doens't resolve on invalid RPC endpoint. HttpProvider promise doesn't resolve on invalid RPC endpoint. Feb 20, 2019
@nivida
Copy link
Contributor

nivida commented Feb 20, 2019

Thanks for creating this issue! I will check, fix and release it asap.

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

Successfully merging a pull request may close this issue.

2 participants