-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Manage provider timeouts #678
Comments
Is this in v4 or v5? For the FallbackProvider, I plan to add a shorter timeout for trying the next in the list of providers. And for throttling status codes, retry with exponential back off is being added. Are these the status codes you are targeting? |
@ricmoo This is v4. I already implemented exponential backoff above for 4XX but I'm wondering if exponential backoff can be done with HTTP timeouts as well. |
I use |
How slow is slow? Why is it slow? If it is a PoA network, you should be able to reduce the pollingInterval to speed it up. It should never timeout... :s |
It's slow because forked ganache proxies calls to external node. I do gas estimation. I found hardcoded timeout in |
@krzkaczor Did you figure out how to get around these timeouts? |
@adrianmcli not really - I suspect that ganache drops the connection, so it's not ethers.js fault. Depending on your case changing this hardcoded timeout in |
@krzkaczor interesting, it seems that doing this gets around it: try {
await myContract.execute(address, callbackData, { gasLimit: 4000000 });
} catch (e) {
if (
e
.toString()
.toLowerCase()
.includes("timeout")
) {
await sleep(60 * 1000); // sleep for extra minute after timeout
} else {
throw e;
}
} I believe this is the hard-coded timeout you are referring to: https://github.com/ethers-io/ethers.js/blob/master/src.ts/utils/web.ts#L44 I also agree that we should be able to easily configure this when we create the provider. |
Seeing this a lot too, most frustrating part is that it doesn't tell you what actually timed out, just that something did, due to minimally helpful Line 91 in 427e168
@adrianmcli as far as I can tell this doesn't actually do anything about the problem though, it gets around it by suppressing the error and then waiting for a magic minute. Doesn't seem very robust. |
I can add the URL to the error. I’ll see what else can be added. I would likely only The error should be on some promise being waited for, so I would think the web fetch would be further down in the stack, so not very useful in general? Not as much as the I’d have to look back at v4 more deeply, but I think you can specify this in the connection object. You can in v5, when connecting, just specify the |
Just looking at the source code for v4, looks like passing in a timeout to the ConnectionInfo object should work fine for setting the timeout. |
@ricmoo The problem I'm seeing is that there's no stack for figuring out which command actually failed after the fact, this is all that appears:
I'm not sure this is improved unless I start putting catch handlers that augment the error with my own message around every async request? |
The latest beta version should include a lot more details on timeouts now. Let me know if it helps you. It includes the URL and request body now... |
I think the error now contains enough extra detail about what timed out that debugging should be much easier, so I'm going to close this. If not though, please feel free to re-open. Thanks! :) |
Might help someone: I used ganache fork (8.0) w/ JsonProviderRPC and for me the issue was that I needed a lot of data from a contract view function. The way ganache fork works is taking a snapshot of the chain and only loading relevant data when you make a transaction. When you need a lot of relevant data it takes time. Reducing the data needed resolved the issue in my case (I needed about 5k values from different contracts, for testing purpose reduced it to 100) |
Hi Richard,
Is it possible to manage timeouts from the provider? I currently use this code to create a "retry provider" for certain status codes. Is it possible to do the same for timeouts?
We deal with this in particular a fair bit:
The text was updated successfully, but these errors were encountered: