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

More helpful error message instead of Failed to subscribe to new newBlockHeaders #3498

Closed
miohtama opened this issue May 4, 2020 · 6 comments
Assignees
Labels
1.x 1.0 related issues Bug Addressing a bug

Comments

@miohtama
Copy link
Contributor

miohtama commented May 4, 2020

Expected behavior

When await web3.eth.send() result, a timeout error gives a helpful error message.

It could say, for example,

web3.js waited the transaction for the configured X seconds. However the transaction was not confirmed before the deadline. The transaction receipt waiting process was aborted, but the transaction might be still confirmed. If you wait for longer, you can configure X or connect web3.js using a WebSocket connection

Also, the thrown Error object could contain a special field so that the library consumer can easily check for this condition and gracefully handle this in the user interface.

Actual behavior

You get an error message Failed to subscribe to new newBlockHeaders to confirm the transaction receipt.

This is strictly not true, as one would be able to confirm the error message if the default timeout 750 seconds is not reached.

Steps to reproduce the behavior

  1. Have an Ethereum node with HTTPS connection and no support for newBlockHeaders, like Infura
  2. Try to send a transaction with a WalletConnect enabled wallet like Trust Wallet or MetaMask Mobile
  3. The default 750 seconds limit is often reached under the current Ethereum mainnet conditions and you will see this error in the console

Environment

  • web3.js 1.2.4
  • WalletConnect 1.0,
  • Trust wallet
@miohtama miohtama changed the title More helpful error message instead of More helpful error message instead of Failed to subscribe to new newBlockHeaders May 4, 2020
@cgewecke cgewecke added 1.x 1.0 related issues Bug Addressing a bug labels May 8, 2020
@cgewecke cgewecke self-assigned this May 14, 2020
@cgewecke
Copy link
Collaborator

@miohtama

Do you think this might be a variant of the bug described in #3432? As you note, your provider is https and it shouldn't be subscribing to anything.

However, it's possible WalletConnect has its own EventEmitter-like interface which Web3 is getting confused by.

If so:

@miohtama
Copy link
Contributor Author

99% of WalletConnect enabled websites are using Infura over HTTPS today, so I think that's where the issue comes from.

Also the underlying issue is that web3.js tries to do too much itself - currently it is a black box how the waiting of a receipt works with await. I would be more brutal and just not do it at all in web3.js. Only support one interface like on and then let the clients do a polling loop with copy-paste code. This way clients have more control over the behavior and they do not need to run into web3.js internal issues which are difficult to solve and very opinionated.

@cgewecke
Copy link
Collaborator

@miohtama Ok thanks.

they do not need to run into web3.js internal issues which are difficult to solve and very opinionated

Agree, the web3-core-methods module is probably the single thing most in need of rationalization / simplification in this project.

@cgewecke
Copy link
Collaborator

@miohtama Are you comfortable with closing this as a duplicate of #3432?

@cgewecke
Copy link
Collaborator

cgewecke commented Jun 3, 2020

@miohtama 1.2.9-rc.0 is published with the patch that might fix this, if you're interested in experimenting with the timeout threshold.

@cgewecke
Copy link
Collaborator

cgewecke commented Jun 9, 2020

1.2.9 (on the premise that it's a duplicate of #3432).

@cgewecke cgewecke closed this as completed Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x 1.0 related issues Bug Addressing a bug
Projects
None yet
Development

No branches or pull requests

2 participants