Differing `wait` and `waitForTransaction` behaviors
See original GitHub issueThis is a bit of an interesting one!
We have a TransactionResponse that we register a wait() callback on a la:
const response = await signer.sendTransaction(...);
response.wait(r => console.log(r)).catch(e => console.log(e))
The response.hash is also passed to a helper that calls provider.waitForTransaction.
The transaction in question (0xd63407185e358f82bb87ec31e91e841fc2d34e8d23c36e7b44ca03573997a7b3 on xdai) hard-errored in wait(), but hung in waitForTransaction. Is there a better way to get the same behavior in both callbacks?
Here are some logs that may be useful for you from the instance:
- Repl check of transaction
> const eth = require("ethers");
> const p = new eth.providers.JsonRpcProvider("https://rpc.xdaichain.com/");
> p.getTransaction("0xd63407185e358f82bb87ec31e91e841fc2d34e8d23c36e7b44ca03573997a7b3").then(r => console.log(r)).catch(e => console.log("error", e))
> null
> p.getTransactionReceipt("0xd63407185e358f82bb87ec31e91e841fc2d34e8d23c36e7b44ca03573997a7b3").then(r => console.log(r)).catch(e => console.log("error", e))
> null
- Error from
waitcallback:
{
"time":1617720629536,
"method":"sendTxAndParseResponse",
"error":{
"message":"processing response error (body=\"{\\\"jsonrpc\\\":\\\"2.0\\\",\\\"error\\\":{\\\"code\\\":-32000,\\\"message\\\":\\\"Block information is incomplete while ancient block sync is still in progress, before it's finished we can't determine the existence of requested item.\\\"},\\\"id\\\":4691}\\n\", error={\"code\":-32000}, requestBody=\"{\\\"method\\\":\\\"eth_getTransactionReceipt\\\",\\\"params\\\":[\\\"0xd63407185e358f82bb87ec31e91e841fc2d34e8d23c36e7b44ca03573997a7b3\\\"],\\\"id\\\":4691,\\\"jsonrpc\\\":\\\"2.0\\\"}\", requestMethod=\"POST\", url=\"https://rpc.xdaichain.com/\", code=SERVER_ERROR, version=web/5.1.0)",
"type":"Error",
"context":{
},
"stack":"Error: processing response error (body=\"{\\\"jsonrpc\\\":\\\"2.0\\\",\\\"error\\\":{\\\"code\\\":-32000,\\\"message\\\":\\\"Block information is incomplete while ancient block sync is still in progress, before it's finished we can't determine the existence of requested item.\\\"},\\\"id\\\":4691}\\n\", error={\"code\":-32000}, requestBody=\"{\\\"method\\\":\\\"eth_getTransactionReceipt\\\",\\\"params\\\":[\\\"0xd63407185e358f82bb87ec31e91e841fc2d34e8d23c36e7b44ca03573997a7b3\\\"],\\\"id\\\":4691,\\\"jsonrpc\\\":\\\"2.0\\\"}\", requestMethod=\"POST\", url=\"https://rpc.xdaichain.com/\", code=SERVER_ERROR, version=web/5.1.0)\n at Logger.makeError (webpack:////app/node_modules/@ethersproject/logger/lib/index.js?:180:21)\n at Logger.throwError (webpack:////app/node_modules/@ethersproject/logger/lib/index.js?:189:20)\n at eval (webpack:////app/node_modules/@ethersproject/web/lib/index.js?:266:32)\n at step (webpack:////app/node_modules/@ethersproject/web/lib/index.js?:33:23)\n at Object.eval [as next] (webpack:////app/node_modules/@ethersproject/web/lib/index.js?:14:53)\n at fulfilled (webpack:////app/node_modules/@ethersproject/web/lib/index.js?:5:58)\n at runMicrotasks (<anonymous>)\n at processTicksAndRejections (internal/process/task_queues.js:93:5)"
},
"msg":"Transaction reverted"
}```
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Documentation - Ethers.js
Ethers' various Classes and Functions are available to import manually ... the transaction has been mined, consider the waitForTransaction method below.
Read more >MySQL 5.6 Reference Manual :: 14.7.1 InnoDB Locking
A transaction waits until the conflicting existing lock is released. If a lock request conflicts with an existing lock and cannot be granted...
Read more >AlchemyWeb3.js Quickstart - Alchemy Docs
This behavior can be configured by passing the following options when creating ... The minimum time waited between consecutive retries, in milliseconds.
Read more >Postgres wait for transaction to finish - database - Stack Overflow
... as the transaction cannot be serialized - then it will fail. That's how it works by design. And, no, you cannot change...
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

There is a difference in
provider.waitForTransactionandtx.wait()that:waitForTransactionwill resolve once transaction is mined even if the actual transaction was success or reverted.tx.waitwill be pending until transaction is mined (using waitForTransaction under the hood) and will resolve or reject based on tx was success or reverted.Hey, what backend were you using? Because this could be a bug in that code base, I think the node should give a JSON RPC ERROR when someone is submitting such a tx (unless there is a pending tx in mempool that is funding this account).