Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add timeout to waitForTransaction #477

Closed
mrwillis opened this issue Mar 29, 2019 · 6 comments
Closed

Feature: Add timeout to waitForTransaction #477

mrwillis opened this issue Mar 29, 2019 · 6 comments
Labels
enhancement New feature or improvement.

Comments

@mrwillis
Copy link

Suppose gas prices spike or something and now your transaction is stuck "in the ether" (~>30 minutes confirmations). Is it possible to have a third parameter in the waitForTransaction(hash, confirmations, timeout)? Currently just wrapping waitForTransaction in a promise that rejects after n seconds.

Also I think the parameters names might be a little off? Could be wrong. For instance in abstract provider, the signature is transactionHash, timeout?, but in BaseProvider it is transactionHash, confirmations?

@ricmoo
Copy link
Member

ricmoo commented Apr 8, 2019

You re absolutely correct, that parameter is misnamed (in v3 it was timeout, but I changed to a confirmation count in v4) and in the code there is an @TODO to put a timeout back in.

That is something I will put back into v5 (public beta coming soon). In the meantime, removing the event listeners will cancel the wait, but there should certainly be an easier way to do that.

@ricmoo ricmoo added discussion Questions, feedback and general information. enhancement New feature or improvement. next version labels Apr 8, 2019
@ricmoo ricmoo changed the title Does waitForTransaction timeout? Feature: Add timeout to waitForTransaction Apr 8, 2019
@gitpusha
Copy link

gitpusha commented Feb 3, 2020

Hi @ricmoo - what is the current recommended way in v4 to set and manage timeouts when waiting for transactions to be mined?

I would like to wait 3 minutes for my transaction to be mined, and if it times out, I would like to resubmit the same tx using the same nonce with a much higher gas price.

Promise wrapping and setTimeout come to mind, but wondering whether you have a built in way that you can recommend?

@ricmoo
Copy link
Member

ricmoo commented Feb 4, 2020

@gitpusha Yes, that is probably the best way to handle it in v4, using a separate timer. This is however, not ideal, since the internal polling loop will continue.

I'll add this to v5 right now, but I probably won't make any changes to the API in v4...

@ricmoo ricmoo added on-deck This Enhancement or Bug is currently being worked on. and removed discussion Questions, feedback and general information. labels Feb 4, 2020
@ricmoo
Copy link
Member

ricmoo commented Feb 4, 2020

I've added support in v5, if anyone would like to try it out. :)

@ricmoo ricmoo removed the on-deck This Enhancement or Bug is currently being worked on. label Feb 7, 2020
@ricmoo
Copy link
Member

ricmoo commented Feb 7, 2020

This has been added to v5. If you have any problems, please feel free to re-open this ticket.

Thanks! :)

@ricmoo ricmoo closed this as completed Feb 7, 2020
@gitpusha
Copy link

@ricmoo cool will try it out !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement.
Projects
None yet
Development

No branches or pull requests

3 participants