tx.wait() never resolves
See original GitHub issueI’m facing a strange issue when testing with ganache and increasing my blockTime
to greater than 0 to simulate network congestion and failures.
The following code works just fine (meaning it fails and returns the reason for failure) when ganache’s blockTime is 0:
try {
let tx = await contractWithSigner.contractFunction(someData, { gasLimit: 1 });
await tx.wait();
} catch (e) { console.log(e); }
As soon as I increase ganache’s blockTime
to any arbitrary number: ganache-cli -b 5
, the same code never resolves the tx.wait()
and ethers is stuck in a loop of sending out a call for transactionReceipt
forever.
I can see in ganache’s output that it does indeed send out the failed transaction receipt message in the block immediately following the contract call. Is my assumption on how this should work incorrect?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:55 (16 by maintainers)
Top Results From Across the Web
tx.wait with Ethers.js never resolves - Stack Overflow
I'm trying to send transactions to the polygon network using ethers.js. After submitting the transaction, i await tx.wait() , but it fails to ......
Read more >tokens - tx.wait() never resolves using ethers library
I am using ethers library in my nodejs , and trying to call a function in smartcontract which looks like: const tx =...
Read more >迁移指南 — ethers.js 中文文档 — 深入浅出区块链
wait() returned a Promise which would resolve to the TransactionResponse once it is mined. In v4, the transaction.wait() returned a Promise which would...
Read more >Documentation - Ethers.js
Send 1 ether to an ens name. const tx = signer. ... If the wait() method on the returned TransactionResponse is called, there...
Read more >would transaction.wait() from ethers.js guarenteed change of ...
I have never run into an issue where the transaction succeeded without value updates. If tx.wait() fails ethers throws an error.
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 FreeTop 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
Top GitHub Comments
issue still relevant
This is a scary way to do it. That should already be what the internal
.wait
is doing, except the.wait
enforces exponential back-off and will use additional hints from the provider to optimize the network usage.If you need an immediate solution, I would recommend using the
provider.waitForTransaction(hash, confirms?, timeout?)
which allows a timeout.I’m looking into this now, and will let you know what I find shortly. 😃