ethers-io / ethers.js

Complete Ethereum library and wallet implementation in JavaScript.
https://ethers.org/
MIT License
7.9k stars 1.83k forks source link

report this; could not find tx or effectiveGasPrice #4652

Open firepol opened 6 months ago

firepol commented 6 months ago

Ethers Version

6.9.0

Search Terms

could not find tx or effectiveGasPrice

Describe the Problem

I do swaps via command line, on uniswap v3 forks or also v2 forks. The transaction is done via command line script and it works, but often I don't get the receipt and get this error:

Error: report this; could not find tx or effectiveGasPrice

Happens often on Telos, chainId 40, but sometimes also on other chains. Can this be caused by the RPC?

Note: the transaction usually works. I check on block explorer and find it. Just my script throws this exception, which I also try to catch without success... the error is not caught. I mean I try to handle it via e?.message but the code crashes before reaching that part.

    try {
      const receipt = await (await method(params, options)).wait() // execute
    } catch (e) {
      let txNotFound = "could not find tx or effectiveGasPrice"
      if (e?.message?.includes(txNotFound) || e?.toString().includes(txNotFound)) {
        // Logger doesn't log it because I never arrive here
        Logger.error(`Error: could not find tx or effectiveGasPrice`)
      } else {
        throw e
      }
    }

So since the error tells me to report this, I'm reporting it ;)

Environment, this happens both if I use a hardhat task or a standalone nodejs script (without hardhat, getting the provider the usual way, via json provider).

Code Snippet

const options = { gasLimit, gasPrice }
const receipt = await (await router.swapExactTokensForTokens(params, options)).wait()

### Contract ABI

_No response_

### Errors

```shell
/myproject/node_modules/ethers/src.ts/providers/abstract-provider.ts:1143
            if (tx == null) { throw new Error("report this; could not find tx or effectiveGasPrice"); }
                                    ^
Error: report this; could not find tx or effectiveGasPrice
    at JsonRpcProvider.getTransactionReceipt (/myproject/node_modules/ethers/src.ts/providers/abstract-provider.ts:1143:37)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at PollingTransactionSubscriber._poll (/myproject/node_modules/ethers/src.ts/providers/subscriber-polling.ts:232:20)


### Environment

node.js (v12 or newer), Hardhat

### Environment (Other)

_No response_
maa105 commented 6 months ago

I got the same issue on metis chain too. Was trying to buy AraFi Token on hermes router. it is intermittent though and I cannot consistently reproduce it.

ricmoo commented 4 months ago

Do you have public endpoints for those chains? It is possible that those chains do not return it (or have renamed it) in their RPC. I need to be able to test it though, so pointing me to RPC endpoints to test with would be helpful :)

firepol commented 4 months ago

Do you have public endpoints for those chains? It is possible that those chains do not return it (or have renamed it) in their RPC. I need to be able to test it though, so pointing me to RPC endpoints to test with would be helpful :)

Try on Telos, but it doesn't happen all the time. Just from time to time...

Try this RPC:

https://mainnet-eu.telos.net/evm

As said, you may need to do many transactions to be able to reproduce this.