Web3.js: web3.eth.sendSignedTransaction promise doesn't resolve as soon as tx is mined

Created on 21 May 2019  路  4Comments  路  Source: ChainSafe/web3.js

Description

We have a bug with Web3 1.0.0-beta.55 (and earlier versions up to 1.0.0-beta.38) when calling https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#methods-mymethod-send - it takes a lot of time to wait despite the transaction is mined. Here are the lines of code where we observe that: https://github.com/poanetwork/posdao-test-setup/blob/2837456e1a4a8d93f632a8b8f49cc617d13b81b1/scripts/deploy-staking-token.js#L50-L59 (steps to reproduce are below).

The same is observed for web3.eth.sendSignedTransaction function.

However, if we change Web3 version to 1.0.0-beta.37, it works fine.

Expected behavior

Calling https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#methods-mymethod-send should finish in a few seconds as soon as the transaction is mined.

Actual behavior

Calling https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#methods-mymethod-send waits for a long time despite the transaction is successfully mined.

Steps to reproduce the behavior

  1. Install Parity 2.4.5-stable.
  2. git clone -b web3-bug https://github.com/poanetwork/posdao-test-setup
  3. cd posdao-test-setup
  4. npm run stop-test-setup
  5. npm run all

After these steps you will see **** Deploying StakingToken message. There should also be StakingToken deployed at: 0x6f7A73c96Bd56f8B0dEBC795511EDA135e105eA3 message in 5-10 seconds but it doesn't appear for a long time.

To stop test setup, perform npm run stop-test-setup command.

The issue is in these lines of code: https://github.com/poanetwork/posdao-test-setup/blob/2837456e1a4a8d93f632a8b8f49cc617d13b81b1/scripts/deploy-staking-token.js#L50-L59

If you change Web3 version to 1.0.0-beta.37 in the package.json and start again with npm run stop-test-setup && npm run all, you will see it works fine: the **** StakingToken deployed at: 0x6f7A73c96Bd56f8B0dEBC795511EDA135e105eA3 message appears after **** Deploying StakingToken in a few seconds.

Error Logs

Just follow the steps to reproduce and you will see that the transaction is mined but the result is not returned by https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#methods-mymethod-send in time.

To see node's logs, open parity-data/node1/log file.

Versions

  • web3.js: 1.0.0-beta.38 ... 1.0.0-beta.55
  • nodejs: v8.11.4
  • ethereum node: Parity 2.4.5-stable
more information needed

Most helpful comment

Yes, that was the reason - I set web3.eth.transactionConfirmationBlocks = 1; and it worked like before. So, I'm closing it. Thanks!

All 4 comments

Thanks, for opening this issue! Did you configure the transactionConfirmationBlocks as described in the documentation of Web3?

I think this is not the issue. I think the default value of transactionConfirmationBlocks is 24, as @nivida suggest if you want tx receipt immediately after the transaction is mined then set transactionConfirmationBlocks to 1.

Tested on Ropsten network with [email protected].

Thanks for the suggestion. I'll try to set transactionConfirmationBlocks explicitly.

Yes, that was the reason - I set web3.eth.transactionConfirmationBlocks = 1; and it worked like before. So, I'm closing it. Thanks!

Was this page helpful?
0 / 5 - 0 ratings