dominant-strategies / quais-5.js

MIT License
1 stars 6 forks source link

`provider.waitForTransaction()` does not resolve if transaction has not been mined #9

Closed Juuddi closed 10 months ago

Juuddi commented 1 year ago

Ethers Version

0.1.14

Search Terms

waitForTransaction, JsonRpcProvider

Describe the Problem

I have the flow:

  1. Send transaction to network via Pelagus API
  2. Once Pelagus has broadcasted tx, initiate provider.waitForTransaction() and wait for it to be mined.
  3. provider.waitForTransaction() should return a promise that resolves to the transaction receipt when it is mined (or if it has already been mined immediately resolve)

When doing this, provider.waitForTransaction is called/used prior to the transaction being mined. Tested about 20 different transactions, each time, the promise hung infinitely and never resolved to the transaction receipt. Verified each time that the function was called prior to the transaction being mined and that the transaction was indeed mined into a block.

The function is intended to act the exact same as provider.getTransactionReceipt if the transaction has been mined. I ran a separate script to test this method with a transaction that had already been mined which correctly returned the transaction receipt.

Also did a test that delayed the running of provider.waitForTransaction() for 3 seconds after the transaction had been broadcasted. This immediately solved my issue and correctly returned the transaction receipt.

These results seems to imply that something with the waiting for transaction to be mined logic is not functioning correctly and resulting in an hanging unresolved promise when the function is called prior to transaction confirmation.

Code Snippet

const receipt = await jsonprovider.waitForTransaction(txhash, 1, 10000)

or 

const receipt = await jsonprovider.waitForTransaction(txhash)

Contract ABI

No response

Errors

No errors, just unresolved promise.

Environment

node.js (v12 or newer)

Environment (Other)

Running a local go-quai instance, using quai-hardhat, Next.js frontend

Juuddi commented 10 months ago

No longer relevant with the removal of polling and the shim package quais-polling