Manage provider timeouts
See original GitHub issueHi 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?
import { JsonRpcProvider } from "ethers/providers";
import { Networkish } from "ethers/utils";
import { ConnectionInfo, poll } from "ethers/utils/web";
export class RetryProvider extends JsonRpcProvider {
public attempts: number;
constructor(
attempts: number,
url?: ConnectionInfo | string,
network?: Networkish
) {
super(url, network);
this.attempts = attempts;
}
public perform(method: string, params: any) {
let attempts = 0;
return poll(() => {
attempts++;
return super.perform(method, params).then(
result => {
return result;
},
(error: any) => {
if (
(error.statusCode === 429 || error.statusCode > 499) &&
attempts < this.attempts
) {
return Promise.resolve(undefined);
} else {
return Promise.reject(error);
}
}
);
});
}
}
We deal with this in particular a fair bit:
2019-12-08 13:03:36 error: Error: timeout at Timeout._onTimeout (/var/app/current/node_modules/ethers/utils/web.js:54:20) at ontimeout (timers.js:436:11) at tryOnTimeout (timers.js:300:5) at listOnTimeout (timers.js:263:5) at Timer.processTimers (timers.js:223:10)
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (6 by maintainers)
Top Results From Across the Web
Resources - Retries and Customizable Timeouts | Terraform
Helpers for handling retries within Resources.
Read more >How to Manage Database Timeouts and Cancellations in Go
One of the great features of Go is that it's possible to cancel database queries while they are still running via a context....
Read more >Types of Timeouts in Credential Provider - CyberArk Community
Generally, there are 3 types of timeout configurations in Credential Provider: [Type 1] In the application - refers to the timeout the SDK ......
Read more >Configure the remote query timeout Server Configuration Option
This topic describes how to configure the remote query timeout server configuration option in SQL Server by using SQL Server Management ...
Read more >Setting request timeout (services) | Cloud Run Documentation
The timeout is set by default to 5 minutes and can be extended up to 60 minutes. Important: For a timeout longer than...
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 FreeTop 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
Top GitHub Comments
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! 😃
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…