WaitForTransaction() incorrectly times out (the transaction was immediately mined)
See original GitHub issueDescribe the bug A transaction was submitted and quickly mined on the network; however, waitForTransaction did not return and in fact ended up failing as if the transaction was not mined/confirmed.
- Transaction submitted:
[2021-04-14 13:04:25.209 +0000] INFO (IndexerAgent/1 on indexer-agent-0): Transaction pending - It is mined at Apr-14-2021 01:04:35 PM +UTC (https://rinkeby.etherscan.io/tx/0xf15ee7523d3943bf1e0880c0e0ff388ed715fe7b0162fe80de9acda88b29581b)
- waitForTransaction timed out thinking that the tx did not get 3 confirmations
[2021-04-14 13:14:24.424 +0000] WARN (IndexerAgent/1 on indexer-agent-0): Failed to send transaction, retrying
Here is the place where waitForTransaction is used in our application: https://github.com/graphprotocol/indexer/blob/552061320c50635094af3b1fdc12d2d981a0e6a1/packages/indexer-agent/src/network.ts#L182-L185
Environment:
- The issue was noticed on a Node application running on a GCloud cluster VM (Ubuntu) talking to an Alchemy API Rinkeby endpoint.
- Ethers v5.1.0
- Using a
StaticJsonRpcProvider
Search Terms waitForTransaction(), transaction incorrectly timed out
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:6 (2 by maintainers)
Top Results From Across the Web
WaitForTransaction() incorrectly times out (the transaction was ...
Describe the bug. A transaction was submitted and quickly mined on the network; however, waitForTransaction did not return and in fact ended up ......
Read more >ERC20 transaction not throwing error but balance is not ...
provider.waitForTransaction(tx.hash,3) . The third argument is milliseconds for timeout error. If you pass 0, it will immediately trigger error.
Read more >tx.wait with Ethers.js never resolves - Stack Overflow
waitForTransaction (hash,confirmations,timeout). You can do something like this: const ethers = require("ethers"); const provider = ...
Read more >Documentation - Ethers.js
To stall until the transaction has been mined, consider the waitForTransaction method below. await provider.getTransactionReceipt(" ...
Read more >web3.eth — web3.js 1.0.0 documentation - Read the Docs
Incorrect checksum addresses will throw an error when passed into functions. ... transactionBlockTimeout; > 50 // set the transaction block timeout web3.eth ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’ve been trying to reproduce this but cannot.
Do you possibly have a long running CPU intensive test that does not yield to the event loop? Are you using your own API key?
Can you try out this script, and see if you see the same problem? I’m wondering if it is a link/firewall issue:
Also, it shouldn’t matter, but can you also remove your
node_modules/,package-lock.json(and yarn lock file if you use yarn) and do a newnpm installto get the latest versions?I’ve also tried setting the number of confirmations to a very large number and the timeout to smaller values, and the timeout seems to be honoured.
If you can tweak this script to reproduce the problem too, that might help me figure out the issue.
Thanks! 😃
@peterbraden What do you mean? It registers a callback using
.on, so it will be called on every block after the transaction is mined. It is not using.once.