question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Manage provider timeouts

See original GitHub issue

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?

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:closed
  • Created 4 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
ricmoocommented, Jul 5, 2020

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! 😃

1reaction
ricmoocommented, Jun 12, 2020

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…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found